Skip to content

normalizeKeyName doesn't have a guard #97

@ryck

Description

@ryck

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);

Your Minimal, Reproducible Example - (Sandbox Highly Recommended)

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions