Skip to content

Comments

fix: handle dead keys in matchesKeyboardEvent#40

Open
ntilwalli wants to merge 2 commits intoTanStack:mainfrom
ntilwalli:fix-dead-key-fallback
Open

fix: handle dead keys in matchesKeyboardEvent#40
ntilwalli wants to merge 2 commits intoTanStack:mainfrom
ntilwalli:fix-dead-key-fallback

Conversation

@ntilwalli
Copy link

🎯 Changes

When event.key is 'Dead' (length 4), the existing event.code fallback—gated behind eventKey.length === 1—was never reached, causing hotkeys to silently fail.

This most commonly affects macOS, where Option+letter combinations like Option+E, Option+I, Option+U, and Option+N produce dead keys for accent composition. It also affects Windows and Linux users with international keyboard layouts (e.g., US-International, German, French) where certain key combinations produce dead keys.

Added an early check: when event.key normalizes to 'Dead', immediately fall back to event.code to extract the physical key via the Key*/Digit* prefixes. Punctuation dead keys (e.g., ' on US-International, where event.code is 'Quote') correctly return false since their codes don't match letter or digit patterns.

✅ Checklist

  • I have followed the steps in the Contributing guide.
  • I have tested this code locally with pnpm run test:pr.

🚀 Release Impact

  • This change affects published code, and I have generated a changeset.
  • This change is docs/CI/dev-only (no release).

When event.key is 'Dead' (length 4), the existing event.code fallback
(gated behind eventKey.length === 1) was never reached, causing hotkeys
to silently fail.

This most commonly affects macOS, where Option+letter combinations like
Option+E, Option+I, Option+U, and Option+N produce dead keys for accent
composition. It also affects Windows and Linux users with international
keyboard layouts (e.g., US-International, German, French) where certain
key combinations produce dead keys.

Adds an early check: when event.key normalizes to 'Dead', immediately
fall back to event.code to extract the physical key via the Key*/Digit*
prefixes. Punctuation dead keys (e.g., apostrophe on US-International,
where event.code is 'Quote') correctly return false since their codes
don't match letter or digit patterns.

Includes 10 tests covering dead key scenarios for letter keys, digit
keys, modifier combinations, mismatches, and missing/invalid codes.

Co-authored-by: Cursor <cursoragent@cursor.com>
@pkg-pr-new
Copy link

pkg-pr-new bot commented Feb 24, 2026

Open in StackBlitz

@tanstack/hotkeys

npm i https://pkg.pr.new/TanStack/hotkeys/@tanstack/hotkeys@40

@tanstack/hotkeys-devtools

npm i https://pkg.pr.new/TanStack/hotkeys/@tanstack/hotkeys-devtools@40

@tanstack/preact-hotkeys

npm i https://pkg.pr.new/TanStack/hotkeys/@tanstack/preact-hotkeys@40

@tanstack/preact-hotkeys-devtools

npm i https://pkg.pr.new/TanStack/hotkeys/@tanstack/preact-hotkeys-devtools@40

@tanstack/react-hotkeys

npm i https://pkg.pr.new/TanStack/hotkeys/@tanstack/react-hotkeys@40

@tanstack/react-hotkeys-devtools

npm i https://pkg.pr.new/TanStack/hotkeys/@tanstack/react-hotkeys-devtools@40

@tanstack/solid-hotkeys

npm i https://pkg.pr.new/TanStack/hotkeys/@tanstack/solid-hotkeys@40

@tanstack/solid-hotkeys-devtools

npm i https://pkg.pr.new/TanStack/hotkeys/@tanstack/solid-hotkeys-devtools@40

commit: dd0307a

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants