fix: firefox bugs

This commit is contained in:
Gabe
2025-10-11 11:19:33 +08:00
parent 9ace600fce
commit 96dfee90ab
10 changed files with 45 additions and 17 deletions

View File

@@ -15,12 +15,20 @@ export const shortcutListener = (
const pressedKeys = new Set();
const handleKeyDown = (e) => {
if (!e.code) {
return;
}
if (pressedKeys.has(e.code)) return;
pressedKeys.add(e.code);
onKeyDown(new Set(pressedKeys), e);
};
const handleKeyUp = (e) => {
if (!e.code) {
return;
}
// onKeyUp 应该在 key 从集合中移除前触发,以便判断组合键
onKeyUp(new Set(pressedKeys), e);
pressedKeys.delete(e.code);