Cleanup knockout commands and replaced EventKeyCode with native KeyboardEvent.key

This commit is contained in:
djmaze 2020-09-17 17:47:35 +02:00
parent d06fed09d6
commit 7ac8143f34
9 changed files with 87 additions and 118 deletions

View file

@ -1,7 +1,7 @@
import ko from 'ko';
import { inFocus } from 'Common/Utils';
import { KeyState, EventKeyCode } from 'Common/Enums';
import { KeyState } from 'Common/Enums';
import { keyScope } from 'Common/Globals';
export class AbstractViewNext {
@ -35,12 +35,12 @@ export class AbstractViewNext {
* @returns {void}
*/
registerPopupKeyDown() {
addEventListener('keydown', (event) => {
addEventListener('keydown', event => {
if (event && this.modalVisibility && this.modalVisibility()) {
if (!this.bDisabeCloseOnEsc && EventKeyCode.Esc === event.keyCode) {
if (!this.bDisabeCloseOnEsc && 'Escape' == event.key) {
this.cancelCommand && this.cancelCommand();
return false;
} else if (EventKeyCode.Backspace === event.keyCode && !inFocus()) {
} else if ('Backspace' == event.key && !inFocus()) {
return false;
}
}