change shortcut e.key to e.code

This commit is contained in:
Gabe Yuan
2023-09-22 15:33:37 +08:00
parent 87f099dd7f
commit 7c67bb7181
3 changed files with 10 additions and 10 deletions

View File

@@ -22,14 +22,14 @@ export const shortcutListener = (fn, target = document, timeout = 3000) => {
}, timeout);
if (e.code) {
allkeys.add(e.key);
curkeys.add(e.key);
allkeys.add(e.code);
curkeys.add(e.code);
fn([...curkeys], [...allkeys]);
}
};
const handleKeyup = (e) => {
curkeys.delete(e.key);
curkeys.delete(e.code);
if (curkeys.size === 0) {
fn([...curkeys], [...allkeys]);
allkeys.clear();