diff --git a/ts/lib/shortcuts.ts b/ts/lib/shortcuts.ts index 5c83f2efa..07c425e67 100644 --- a/ts/lib/shortcuts.ts +++ b/ts/lib/shortcuts.ts @@ -100,8 +100,6 @@ function check( ); } -const shortcutTimeoutMs = 400; - function innerShortcut( lastEvent: KeyboardEvent, callback: (event: KeyboardEvent) => void, @@ -119,14 +117,12 @@ function innerShortcut( if (check(event, optionalModifiers, nextKey)) { innerShortcut(event, callback, optionalModifiers, ...restKeys); clearTimeout(interval); + } else if (event.location === 0) { + // Any non-modifier key will cancel the shortcut sequence + document.removeEventListener("keydown", handler); } }; - interval = setTimeout( - (): void => document.removeEventListener("keydown", handler), - shortcutTimeoutMs - ); - document.addEventListener("keydown", handler, { once: true }); } }