Added menu key (#245)

Resolves #243
This commit is contained in:
Nejc Zdovc
2017-01-02 22:21:47 +01:00
committed by József Farkas
parent de0f06e7e4
commit ae7d90e634
3 changed files with 21 additions and 6 deletions
@@ -11,16 +11,22 @@ export class CaptureKeystrokeButtonComponent {
private record: boolean; private record: boolean;
private first: boolean; // enable usage of Enter to start capturing private first: boolean; // enable usage of Enter to start capturing
private scanCodePressed: boolean;
constructor(private captureService: CaptureService) { constructor(private captureService: CaptureService) {
this.record = false; this.record = false;
this.captureService.initModifiers(); this.captureService.initModifiers();
this.captureService.populateMapping(); this.captureService.populateMapping();
this.scanCodePressed = false;
} }
@HostListener('keyup') @HostListener('keyup', ['$event'])
onKeyUp() { onKeyUp(e: KeyboardEvent) {
if (this.record && !this.first) { if (this.scanCodePressed) {
e.preventDefault();
this.scanCodePressed = false;
} else if (this.record && !this.first) {
e.preventDefault();
this.saveScanCode(); this.saveScanCode();
} }
} }
@@ -37,6 +43,7 @@ export class CaptureKeystrokeButtonComponent {
if (this.captureService.hasMap(code)) { if (this.captureService.hasMap(code)) {
this.saveScanCode(this.captureService.getMap(code)); this.saveScanCode(this.captureService.getMap(code));
this.scanCodePressed = true;
} else { } else {
this.captureService.setModifier((e.location === 1), code); this.captureService.setModifier((e.location === 1), code);
} }
@@ -84,6 +84,7 @@ export class SvgKeyboardKeyComponent implements OnInit, OnChanges, OnDestroy {
private macros: Macro[]; private macros: Macro[];
private subscription: Subscription; private subscription: Subscription;
private recording: boolean; private recording: boolean;
private scanCodePressed: boolean;
@HostListener('click') @HostListener('click')
onClick() { onClick() {
@@ -106,9 +107,13 @@ export class SvgKeyboardKeyComponent implements OnInit, OnChanges, OnDestroy {
} }
} }
@HostListener('keyup') @HostListener('keyup', ['$event'])
onKeyUp() { onKeyUpe(e: KeyboardEvent) {
if (this.recording) { if (this.scanCodePressed) {
e.preventDefault();
this.scanCodePressed = false;
} else if (this.recording) {
e.preventDefault();
this.saveScanCode(); this.saveScanCode();
} }
} }
@@ -122,6 +127,7 @@ export class SvgKeyboardKeyComponent implements OnInit, OnChanges, OnDestroy {
if (this.captureService.hasMap(code)) { if (this.captureService.hasMap(code)) {
this.saveScanCode(this.captureService.getMap(code)); this.saveScanCode(this.captureService.getMap(code));
this.scanCodePressed = true;
} else { } else {
this.captureService.setModifier((e.location === 1), code); this.captureService.setModifier((e.location === 1), code);
} }
@@ -145,6 +151,7 @@ export class SvgKeyboardKeyComponent implements OnInit, OnChanges, OnDestroy {
this.reset(); this.reset();
this.captureService.populateMapping(); this.captureService.populateMapping();
this.scanCodePressed = false;
} }
ngOnInit() { ngOnInit() {
+1
View File
@@ -94,6 +94,7 @@ export class CaptureService {
this.mapping.set(88, 27); // X this.mapping.set(88, 27); // X
this.mapping.set(89, 28); // Y this.mapping.set(89, 28); // Y
this.mapping.set(90, 29); // Z this.mapping.set(90, 29); // Z
this.mapping.set(93, 118); // Menu
this.mapping.set(96, 98); // Num pad 0 this.mapping.set(96, 98); // Num pad 0
this.mapping.set(97, 89); // Num pad 1 this.mapping.set(97, 89); // Num pad 1
this.mapping.set(98, 90); // Num pad 2 this.mapping.set(98, 90); // Num pad 2