Skip to content

Commit 1994b7f

Browse files
authored
Merge pull request #3 from humanlayer/publish-humanlayer
fix: prevent code-based fallback when useKey is true
2 parents b51061c + 7f22d24 commit 1994b7f

3 files changed

Lines changed: 11 additions & 4 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@humanlayer/react-hotkeys-hook",
33
"description": "React hook for handling keyboard shortcuts (HumanLayer fork)",
4-
"version": "5.2.5",
4+
"version": "5.2.6",
55
"sideEffects": false,
66
"repository": {
77
"type": "git",

packages/react-hotkeys-hook/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-hotkeys-hook",
3-
"version": "5.2.5",
3+
"version": "5.2.6",
44
"type": "module",
55
"scripts": {
66
"dev": "vite",

packages/react-hotkeys-hook/src/lib/validators.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,15 @@ export const isHotkeyMatchingKeyboardEvent = (e: KeyboardEvent, hotkey: Hotkey,
125125

126126
// All modifiers are correct, now check the key
127127
// If useKey is set, match against the produced key value instead of the key code
128-
if (useKey && keys?.length === 1 && keys.includes(producedKey.toLowerCase())) {
129-
return true
128+
// When useKey is true, we ONLY match produced keys — never fall through to code-based matching
129+
if (useKey) {
130+
if (keys?.length === 1) {
131+
return keys.includes(producedKey.toLowerCase())
132+
}
133+
if (keys && keys.length > 0) {
134+
return isHotkeyPressed(keys.map((k) => k.toLowerCase()))
135+
}
136+
return !keys || keys.length === 0
130137
}
131138

132139
// If the key is set, we check for the key

0 commit comments

Comments
 (0)