Skip to content
Source
Sign inSign up
TanStack/hotkeys

normalizeKeyName doesn't have a guard #97

Closedryck(GitHub profile, opens in a new tab) opened this issue 0 comments

TanStack Hotkeys version

v0.9.0

Framework/Library version

React v19.2.4

Describe the bug and the steps to reproduce it

normalizeKeyName calls key.toUpperCase() without guarding against undefined, and event.key can be undefined in rare cases (browser extensions synthesizing key events, accessibility tools, certain OS/browser combinations).

To reproduce it, just paste this code in console of a project with hotkeys:

const event = new KeyboardEvent('keydown', { bubbles: true });
Object.defineProperty(event, 'key', { get: () => undefined });
document.dispatchEvent(event);

https://codesandbox.io/p/sandbox/purple-wood-3d74qc

Screenshots or Videos (Optional)

No response

Do you intend to try to help solve this bug with your own PR?

Yes, I am also opening a PR that solves the problem along side this issue

Terms & Code of Conduct

  • I agree to follow this project's Code of Conduct
  • I understand that if my bug cannot be reliable reproduced in a debuggable environment, it will probably not be fixed and this issue may even be closed.
  1. KevinVandy closed this

Sign in to join this conversation.