diff --git a/packages/use-keyboard-shortcuts/package.json b/packages/use-keyboard-shortcuts/package.json index 206652a8..7cc55a1d 100644 --- a/packages/use-keyboard-shortcuts/package.json +++ b/packages/use-keyboard-shortcuts/package.json @@ -1,6 +1,6 @@ { "name": "@bytelyst/use-keyboard-shortcuts", - "version": "0.1.7", + "version": "0.1.8", "type": "module", "exports": { ".": { diff --git a/packages/use-keyboard-shortcuts/src/use-keyboard-shortcuts.ts b/packages/use-keyboard-shortcuts/src/use-keyboard-shortcuts.ts index 75657404..fd4a0981 100644 --- a/packages/use-keyboard-shortcuts/src/use-keyboard-shortcuts.ts +++ b/packages/use-keyboard-shortcuts/src/use-keyboard-shortcuts.ts @@ -32,9 +32,11 @@ export function useKeyboardShortcuts(shortcuts: ShortcutDef[]): void { } function handleKeyDown(e: KeyboardEvent) { + if (!e.key) return; const inInput = isInputElement(e.target); for (const shortcut of shortcuts) { + if (!shortcut.key) continue; const metaMatch = shortcut.meta ? e.metaKey || e.ctrlKey : !(e.metaKey || e.ctrlKey); const shiftMatch = shortcut.shift ? e.shiftKey : !e.shiftKey; const altMatch = shortcut.alt ? e.altKey : !e.altKey;