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

View File

@@ -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);
}

View File

@@ -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() {

View File

@@ -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