feat: Make Right click, Esc set the key action to none (#897)

* feat: Make Right click, Esc set the key action to none

* refactor: use ts-keycode-enum; revert: escape from mapping on pressing escape.
This commit is contained in:
dgyimesi
2019-01-24 14:25:22 +01:00
committed by László Monda
parent d674fd4490
commit c36156b497
6 changed files with 566 additions and 547 deletions
@@ -8,6 +8,8 @@ import { Store } from '@ngrx/store';
import { Subscription } from 'rxjs/Subscription';
import { Key } from 'ts-keycode-enum';
import {
KeyAction,
KeyModifiers,
@@ -152,11 +154,11 @@ export class SvgKeyboardKeyComponent implements OnInit, OnChanges, OnDestroy {
@HostListener('document:keyup', ['$event'])
onKeyUp(e: KeyboardEvent) {
if (e.keyCode === 18 && this.pressedAltLocation > -1) {
if (e.keyCode === Key.Alt && this.pressedAltLocation > -1) {
this.pressedAltLocation = -1;
e.preventDefault();
}
else if (e.keyCode === 16 && this.pressedShiftLocation > -1) {
else if (e.keyCode === Key.Shift && this.pressedShiftLocation > -1) {
this.pressedShiftLocation = -1;
e.preventDefault();
}
@@ -180,11 +182,11 @@ export class SvgKeyboardKeyComponent implements OnInit, OnChanges, OnDestroy {
// If the Alt or Shift key not released after start the capturing
// then add them as a modifier
if (this.pressedShiftLocation > -1) {
this.captureService.setModifier((this.pressedShiftLocation === 1), 16);
this.captureService.setModifier((this.pressedShiftLocation === 1), Key.Shift);
}
if (this.pressedAltLocation > -1) {
this.captureService.setModifier((this.pressedAltLocation === 1), 18);
this.captureService.setModifier((this.pressedAltLocation === 1), Key.Alt);
}
this.saveScanCode(this.captureService.getMap(code));
@@ -193,11 +195,11 @@ export class SvgKeyboardKeyComponent implements OnInit, OnChanges, OnDestroy {
this.captureService.setModifier((e.location === 1), code);
}
} else {
if (e.keyCode === 16) {
if (e.keyCode === Key.Shift) {
this.pressedShiftLocation = e.location;
}
if (e.keyCode === 18) {
if (e.keyCode === Key.Alt) {
this.pressedAltLocation = e.location;
}
}