From 5ef056a23e7acb1f78820d99ce5382ffc456aeaf Mon Sep 17 00:00:00 2001 From: Henrik Giesel Date: Fri, 21 May 2021 19:03:06 +0200 Subject: [PATCH] Make numpad keys also cancel current shortcut sequence --- ts/lib/shortcuts.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ts/lib/shortcuts.ts b/ts/lib/shortcuts.ts index 81f14199b..24a75202e 100644 --- a/ts/lib/shortcuts.ts +++ b/ts/lib/shortcuts.ts @@ -105,6 +105,9 @@ function check( ); } +const GENERAL_KEY = 0; +const NUMPAD_KEY = 3; + function innerShortcut( lastEvent: KeyboardEvent, callback: (event: KeyboardEvent) => void, @@ -122,7 +125,7 @@ function innerShortcut( if (check(event, optionalModifiers, nextKey)) { innerShortcut(event, callback, optionalModifiers, ...restKeys); clearTimeout(interval); - } else if (event.location === 0) { + } else if (event.location === GENERAL_KEY || event.location === NUMPAD_KEY) { // Any non-modifier key will cancel the shortcut sequence document.removeEventListener("keydown", handler); }