diff --git a/package.json b/package.json index 4b1e54b1..bc83dd80 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@humanlayer/react-hotkeys-hook", "description": "React hook for handling keyboard shortcuts (HumanLayer fork)", - "version": "5.2.5", + "version": "5.2.6", "sideEffects": false, "repository": { "type": "git", diff --git a/packages/react-hotkeys-hook/package.json b/packages/react-hotkeys-hook/package.json index 64f44efb..cdad55c5 100644 --- a/packages/react-hotkeys-hook/package.json +++ b/packages/react-hotkeys-hook/package.json @@ -1,6 +1,6 @@ { "name": "react-hotkeys-hook", - "version": "5.2.5", + "version": "5.2.6", "type": "module", "scripts": { "dev": "vite", diff --git a/packages/react-hotkeys-hook/src/lib/validators.ts b/packages/react-hotkeys-hook/src/lib/validators.ts index 9044f133..02f5c65c 100644 --- a/packages/react-hotkeys-hook/src/lib/validators.ts +++ b/packages/react-hotkeys-hook/src/lib/validators.ts @@ -125,8 +125,15 @@ export const isHotkeyMatchingKeyboardEvent = (e: KeyboardEvent, hotkey: Hotkey, // All modifiers are correct, now check the key // If useKey is set, match against the produced key value instead of the key code - if (useKey && keys?.length === 1 && keys.includes(producedKey.toLowerCase())) { - return true + // When useKey is true, we ONLY match produced keys — never fall through to code-based matching + if (useKey) { + if (keys?.length === 1) { + return keys.includes(producedKey.toLowerCase()) + } + if (keys && keys.length > 0) { + return isHotkeyPressed(keys.map((k) => k.toLowerCase())) + } + return !keys || keys.length === 0 } // If the key is set, we check for the key