Ctrl+Backquote never matches when Chrome on Linux Wayland reports key "Unidentified" #229
What happens#
On Chrome 156, Fedora 44, KDE Plasma on Wayland, pressing Ctrl+` sends this keydown:
| Field | Value |
|---|---|
key | Unidentified |
code | Backquote |
keyCode | 192 |
isComposing | false |
ctrlKey | true |
It happens on both the us and ua layouts. Neither Control+`` nor Control+[Backquote]` fires.
Why#
normalizeKeyboardEvent in packages/hotkeys/src/_keyboard-event.ts marks every Unidentified key as isComposing, so matchKeyboardEvent returns no match before it checks parsed.code. The event has keyCode 192 and isComposing: false, so nothing is being composed.
The logical binding then fails a second time. positionStandsIn in packages/hotkeys/src/_match.ts lets a Dead key fall back to event.code, but not an Unidentified one.
Repro on 0.24.0#
import { matchesKeyboardEvent } from '@tanstack/hotkeys'
const event = { key: 'Unidentified', code: 'Backquote', keyCode: 192, ctrlKey: true, shiftKey: false, altKey: false, metaKey: false }
matchesKeyboardEvent(event, 'Control+`', 'linux') // false
matchesKeyboardEvent(event, 'Control+[Backquote]', 'linux') // false
Suggested fix#
// packages/hotkeys/src/_keyboard-event.ts
isComposing:
Boolean(event.isComposing) ||
event.keyCode === 229 ||
key === 'Process' ||
- key === 'Unidentified',
+ (key === 'Unidentified' && !event.ctrlKey && !event.metaKey),
// packages/hotkeys/src/_match.ts
- if (key !== 'Dead' && !isPrintableKey(key)) return false
+ if (key !== 'Dead' && key !== 'Unidentified' && !isPrintableKey(key)) return false
I applied the same two changes to the built 0.24.0 dist files. With them, both bindings above match. An Unidentified key on another physical key still doesn't match Control+``, and neither does an Unidentified` key without Ctrl or Meta. I haven't run the repo's test suite.
On 0.7.1, which our app uses, the same fallback added with patch-package fixed the shortcut in real use. All 16 presses fired.
The empty key is probably a Chromium bug on Wayland. Still, event.code names a real key here, so the library could match it.
Sign in to join this conversation.