mirror of
https://github.com/ankitects/anki.git
synced 2025-09-23 16:26:40 -04:00
Make numpad keys also cancel current shortcut sequence
This commit is contained in:
parent
9d212487c6
commit
5ef056a23e
1 changed files with 4 additions and 1 deletions
|
@ -105,6 +105,9 @@ function check(
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const GENERAL_KEY = 0;
|
||||||
|
const NUMPAD_KEY = 3;
|
||||||
|
|
||||||
function innerShortcut(
|
function innerShortcut(
|
||||||
lastEvent: KeyboardEvent,
|
lastEvent: KeyboardEvent,
|
||||||
callback: (event: KeyboardEvent) => void,
|
callback: (event: KeyboardEvent) => void,
|
||||||
|
@ -122,7 +125,7 @@ function innerShortcut(
|
||||||
if (check(event, optionalModifiers, nextKey)) {
|
if (check(event, optionalModifiers, nextKey)) {
|
||||||
innerShortcut(event, callback, optionalModifiers, ...restKeys);
|
innerShortcut(event, callback, optionalModifiers, ...restKeys);
|
||||||
clearTimeout(interval);
|
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
|
// Any non-modifier key will cancel the shortcut sequence
|
||||||
document.removeEventListener("keydown", handler);
|
document.removeEventListener("keydown", handler);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue