diff --git a/src/components/popover/widgets/capture-keystroke/capture-keystroke-button.component.ts b/src/components/popover/widgets/capture-keystroke/capture-keystroke-button.component.ts index 0aed29c0..c89b2d3b 100644 --- a/src/components/popover/widgets/capture-keystroke/capture-keystroke-button.component.ts +++ b/src/components/popover/widgets/capture-keystroke/capture-keystroke-button.component.ts @@ -11,16 +11,22 @@ export class CaptureKeystrokeButtonComponent { private record: boolean; private first: boolean; // enable usage of Enter to start capturing + private scanCodePressed: boolean; constructor(private captureService: CaptureService) { this.record = false; this.captureService.initModifiers(); this.captureService.populateMapping(); + this.scanCodePressed = false; } - @HostListener('keyup') - onKeyUp() { - if (this.record && !this.first) { + @HostListener('keyup', ['$event']) + onKeyUp(e: KeyboardEvent) { + if (this.scanCodePressed) { + e.preventDefault(); + this.scanCodePressed = false; + } else if (this.record && !this.first) { + e.preventDefault(); this.saveScanCode(); } } @@ -37,6 +43,7 @@ export class CaptureKeystrokeButtonComponent { if (this.captureService.hasMap(code)) { this.saveScanCode(this.captureService.getMap(code)); + this.scanCodePressed = true; } else { this.captureService.setModifier((e.location === 1), code); } diff --git a/src/components/svg/keys/svg-keyboard-key/svg-keyboard-key.component.ts b/src/components/svg/keys/svg-keyboard-key/svg-keyboard-key.component.ts index 90e967f7..dee4ed08 100644 --- a/src/components/svg/keys/svg-keyboard-key/svg-keyboard-key.component.ts +++ b/src/components/svg/keys/svg-keyboard-key/svg-keyboard-key.component.ts @@ -84,6 +84,7 @@ export class SvgKeyboardKeyComponent implements OnInit, OnChanges, OnDestroy { private macros: Macro[]; private subscription: Subscription; private recording: boolean; + private scanCodePressed: boolean; @HostListener('click') onClick() { @@ -106,9 +107,13 @@ export class SvgKeyboardKeyComponent implements OnInit, OnChanges, OnDestroy { } } - @HostListener('keyup') - onKeyUp() { - if (this.recording) { + @HostListener('keyup', ['$event']) + onKeyUpe(e: KeyboardEvent) { + if (this.scanCodePressed) { + e.preventDefault(); + this.scanCodePressed = false; + } else if (this.recording) { + e.preventDefault(); this.saveScanCode(); } } @@ -122,6 +127,7 @@ export class SvgKeyboardKeyComponent implements OnInit, OnChanges, OnDestroy { if (this.captureService.hasMap(code)) { this.saveScanCode(this.captureService.getMap(code)); + this.scanCodePressed = true; } else { this.captureService.setModifier((e.location === 1), code); } @@ -145,6 +151,7 @@ export class SvgKeyboardKeyComponent implements OnInit, OnChanges, OnDestroy { this.reset(); this.captureService.populateMapping(); + this.scanCodePressed = false; } ngOnInit() { diff --git a/src/services/capture.service.ts b/src/services/capture.service.ts index dbb4b84b..ff141905 100644 --- a/src/services/capture.service.ts +++ b/src/services/capture.service.ts @@ -94,6 +94,7 @@ export class CaptureService { this.mapping.set(88, 27); // X this.mapping.set(89, 28); // Y this.mapping.set(90, 29); // Z + this.mapping.set(93, 118); // Menu this.mapping.set(96, 98); // Num pad 0 this.mapping.set(97, 89); // Num pad 1 this.mapping.set(98, 90); // Num pad 2