From 506bf002b2f9ab47d0b447fdceea0f802c309245 Mon Sep 17 00:00:00 2001 From: Stefan Mansson Date: Tue, 17 Jan 2023 17:51:06 +0200 Subject: [PATCH 1/2] fix: fix keyup block repeated actions --- src/useHotkeys.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/useHotkeys.ts b/src/useHotkeys.ts index 35b7fbdb..9633456a 100644 --- a/src/useHotkeys.ts +++ b/src/useHotkeys.ts @@ -65,7 +65,9 @@ export default function useHotkeys( parseKeysHookInput(keys, memoisedOptions?.splitKey).forEach((key) => { const hotkey = parseHotkey(key, memoisedOptions?.combinationKey) - if ((isHotkeyMatchingKeyboardEvent(e, hotkey, memoisedOptions?.ignoreModifiers) || hotkey.keys?.includes('*')) && !hasTriggeredRef.current) { + if (isHotkeyMatchingKeyboardEvent(e, hotkey, memoisedOptions?.ignoreModifiers) || hotkey.keys?.includes('*')) { + if (isKeyUp && hasTriggeredRef.current) return + maybePreventDefault(e, hotkey, memoisedOptions?.preventDefault) if (!isHotkeyEnabled(e, hotkey, memoisedOptions?.enabled)) { From 1bc401dadfdc8c12f888fd8d166c6f8e9dafc2a7 Mon Sep 17 00:00:00 2001 From: Stefan Mansson Date: Tue, 17 Jan 2023 18:12:10 +0200 Subject: [PATCH 2/2] fix: non-meta keys being fired --- src/validators.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/validators.ts b/src/validators.ts index a94a9ead..46238516 100644 --- a/src/validators.ts +++ b/src/validators.ts @@ -73,7 +73,7 @@ export const isHotkeyMatchingKeyboardEvent = (e: KeyboardEvent, hotkey: Hotkey, return false } } else { - if (metaKey !== meta && ctrlKey !== meta && keyCode !== 'meta' && keyCode !== 'ctrl') { + if (metaKey !== meta && ctrlKey !== meta) { return false } }