mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-04-23 01:08:28 +02:00
Fix hotkey state messing up on Enter->submit
This commit is contained in:
@@ -91,6 +91,12 @@ export function useHotKey(
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Don't add key if not holding modifier
|
||||||
|
const isHoldingModifier = e.altKey || e.ctrlKey || e.metaKey || e.shiftKey;
|
||||||
|
if (!isHoldingModifier) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const key = normalizeKey(e.key, os);
|
const key = normalizeKey(e.key, os);
|
||||||
|
|
||||||
// Don't add hold keys
|
// Don't add hold keys
|
||||||
@@ -127,6 +133,7 @@ export function useHotKey(
|
|||||||
|
|
||||||
clearCurrentKeys();
|
clearCurrentKeys();
|
||||||
};
|
};
|
||||||
|
|
||||||
const up = (e: KeyboardEvent) => {
|
const up = (e: KeyboardEvent) => {
|
||||||
if (options.enable === false) {
|
if (options.enable === false) {
|
||||||
return;
|
return;
|
||||||
@@ -142,8 +149,9 @@ export function useHotKey(
|
|||||||
currentKeys.current.clear();
|
currentKeys.current.clear();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
document.addEventListener('keydown', down, { capture: true });
|
|
||||||
document.addEventListener('keyup', up, { capture: true });
|
document.addEventListener('keyup', up, { capture: true });
|
||||||
|
document.addEventListener('keydown', down, { capture: true });
|
||||||
return () => {
|
return () => {
|
||||||
document.removeEventListener('keydown', down, { capture: true });
|
document.removeEventListener('keydown', down, { capture: true });
|
||||||
document.removeEventListener('keyup', up, { capture: true });
|
document.removeEventListener('keyup', up, { capture: true });
|
||||||
|
|||||||
Reference in New Issue
Block a user