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:
@@ -1,6 +1,8 @@
|
||||
import { ChangeDetectionStrategy, Component, EventEmitter, HostListener, Input, Output } from '@angular/core';
|
||||
import { Store } from '@ngrx/store';
|
||||
|
||||
import { Key } from 'ts-keycode-enum';
|
||||
|
||||
import { CaptureService } from '../../../../services/capture.service';
|
||||
import { KeyModifierModel } from '../../../../models/key-modifier-model';
|
||||
import { AppState } from '../../../../store';
|
||||
@@ -45,7 +47,6 @@ export class CaptureKeystrokeButtonComponent {
|
||||
@HostListener('keydown', ['$event'])
|
||||
onKeyDown(e: KeyboardEvent) {
|
||||
const code: number = e.keyCode;
|
||||
const enter = 13;
|
||||
|
||||
if (this.record) {
|
||||
e.preventDefault();
|
||||
@@ -58,7 +59,7 @@ export class CaptureKeystrokeButtonComponent {
|
||||
} else {
|
||||
this.captureService.setModifier((e.location === 1), code);
|
||||
}
|
||||
} else if (code === enter) {
|
||||
} else if (code === Key.Enter) {
|
||||
this.record = true;
|
||||
this.first = true;
|
||||
this.store.dispatch(new StartKeypressCapturingAction());
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user