fix(hotkeys): Stop AltGr shortcuts from firing unmodified hotkeys #193
main fromrefs/pull/193/head·merged by KevinVandy Related to https://github.com/TanStack/hotkeys/discussions/168
- AltGr with a key that types nothing new, such as AltGr+Home, or AltGr+F on Windows Norwegian, no longer fires
HomeorF. - On Windows, which reports AltGr as Control+Alt, those presses fire
Control+Althotkeys instead, as in native Windows apps.Control+Alt+Homecatches AltGr+Home, and the recorder records it asMod+Alt+[Home]. On Linux, AltGr isn't Control+Alt, so those presses fire nothing. - Characters typed with AltGr, such as
@or€, still match as before and never triggerControl+Althotkeys. - No public types change. The fix is in
normalizeKeyboardEventand the matcher, so matching,parseKeyboardEvent, and the recorder all agree. - New
e2e/workspace:pnpm test:e2eruns Playwright tests for chords, inputs and focus, sequences, scopes, held keys, and the recorder in Chromium, Firefox, and WebKit.pnpm test:e2e:layoutspresses real keys through Linux keyboard layouts (AltGr, AZERTY, QWERTZ, Dvorak, Russian, dead keys) with Xvfb,setxkbmap, andxdotool.pnpm test:e2e:layouts:dockerruns the same suite from macOS.
- New
E2Eworkflow runs both suites on every pull request.
Notes#
The Windows behavior is covered only by unit tests with simulated event shapes, because CI can't press real keys on Windows. The new workflow adds two jobs to every pull request.
Summary by CodeRabbit#
- Bug Fixes
- AltGr key handling is more consistent across Windows and Linux: characters typed with AltGr continue to match their character shortcuts, while AltGr presses that produce no character no longer trigger ordinary shortcuts. On Windows, these presses can match Control+Alt shortcuts and are recorded as Control+Alt.
- Tests
- Added end-to-end coverage for keyboard shortcuts, focus, sequences, scopes, recording, and keyboard layouts across major browsers.
- Documentation
- Clarified platform-specific AltGr behavior and added guidance for running end-to-end tests.
- 1
🚀 Changeset Version Preview#
1 package(s) bumped directly, 17 bumped as dependents.
🟩 Patch bumps#
Package Version Reason @tanstack/hotkeys0.16.0 → 0.16.1 Changeset @tanstack/alpine-hotkeys0.4.0 → 0.4.1 Dependent @tanstack/angular-hotkeys0.15.0 → 0.15.1 Dependent @tanstack/angular-hotkeys-devtools0.2.8 → 0.2.9 Dependent @tanstack/ember-hotkeys0.4.0 → 0.4.1 Dependent @tanstack/hotkeys-devtools1.4.0 → 1.4.1 Dependent @tanstack/lit-hotkeys0.16.0 → 0.16.1 Dependent @tanstack/octane-hotkeys0.5.0 → 0.5.1 Dependent @tanstack/preact-hotkeys0.15.0 → 0.15.1 Dependent @tanstack/preact-hotkeys-devtools0.10.8 → 0.10.9 Dependent @tanstack/react-hotkeys0.15.0 → 0.15.1 Dependent @tanstack/react-hotkeys-devtools0.10.8 → 0.10.9 Dependent @tanstack/solid-hotkeys0.15.0 → 0.15.1 Dependent @tanstack/solid-hotkeys-devtools0.10.8 → 0.10.9 Dependent @tanstack/svelte-hotkeys0.15.0 → 0.15.1 Dependent @tanstack/svelte-hotkeys-devtools0.2.8 → 0.2.9 Dependent @tanstack/vue-hotkeys0.15.0 → 0.15.1 Dependent @tanstack/vue-hotkeys-devtools0.10.8 → 0.10.9 Dependent Review the following changes in direct dependencies. Learn more about Socket for GitHub.
Diff Package Supply Chain
SecurityVulnerability Quality Maintenance License @playwright/test@1.63.0 @tanstack/alpine-hotkeys
npm i https://pkg.pr.new/@tanstack/alpine-hotkeys@193@tanstack/angular-hotkeys
npm i https://pkg.pr.new/@tanstack/angular-hotkeys@193@tanstack/angular-hotkeys-devtools
npm i https://pkg.pr.new/@tanstack/angular-hotkeys-devtools@193@tanstack/ember-hotkeys
npm i https://pkg.pr.new/@tanstack/ember-hotkeys@193@tanstack/hotkeys
npm i https://pkg.pr.new/@tanstack/hotkeys@193@tanstack/hotkeys-devtools
npm i https://pkg.pr.new/@tanstack/hotkeys-devtools@193@tanstack/lit-hotkeys
npm i https://pkg.pr.new/@tanstack/lit-hotkeys@193@tanstack/octane-hotkeys
npm i https://pkg.pr.new/@tanstack/octane-hotkeys@193@tanstack/preact-hotkeys
npm i https://pkg.pr.new/@tanstack/preact-hotkeys@193@tanstack/preact-hotkeys-devtools
npm i https://pkg.pr.new/@tanstack/preact-hotkeys-devtools@193@tanstack/react-hotkeys
npm i https://pkg.pr.new/@tanstack/react-hotkeys@193@tanstack/react-hotkeys-devtools
npm i https://pkg.pr.new/@tanstack/react-hotkeys-devtools@193@tanstack/solid-hotkeys
npm i https://pkg.pr.new/@tanstack/solid-hotkeys@193@tanstack/solid-hotkeys-devtools
npm i https://pkg.pr.new/@tanstack/solid-hotkeys-devtools@193@tanstack/svelte-hotkeys
npm i https://pkg.pr.new/@tanstack/svelte-hotkeys@193@tanstack/svelte-hotkeys-devtools
npm i https://pkg.pr.new/@tanstack/svelte-hotkeys-devtools@193@tanstack/vue-hotkeys
npm i https://pkg.pr.new/@tanstack/vue-hotkeys@193@tanstack/vue-hotkeys-devtools
npm i https://pkg.pr.new/@tanstack/vue-hotkeys-devtools@193commit:
b0108b3No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
-
⚙️ Run configuration
-
- Configuration used: Repository: TanStack/hotkeys/.coderabbit.yaml
- Review profile: CHILL
- Plan: Advanced
- Run ID:
70e9b640-4ea8-4e63-bf52-e271328a03ad
📥 Commits
-
Reviewing files that changed from the base of the PR and between ad56a4b0dbf3c34d8552eca2cc88c5c7000d520a and b0108b3b092044c30fedd83b1a2a7abbfa5550e3.
⛔ Files ignored due to path filters: 2
-
docs/reference/classes/HotkeyRecorder.mdis excluded by!docs/**/reference/**pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml,!**/pnpm-lock.yaml
📒 Files selected for processing: 33
-
.changeset/altgr-control-alt.md.github/workflows/e2e.yml.prettierignoreCONTRIBUTING.mddocs/guides/sensible-defaults.mde2e/.gitignoree2e/README.mde2e/browser/chords.spec.tse2e/browser/focus.spec.tse2e/browser/held-keys-and-recorder.spec.tse2e/browser/sequences-and-scopes.spec.tse2e/docker/Dockerfilee2e/docker/tanstack.xkbe2e/eslint.config.jse2e/layouts/alt-graph.spec.tse2e/layouts/layouts.spec.tse2e/package.jsone2e/playwright.config.tse2e/playwright.layouts.config.tse2e/scripts/layouts-docker.tse2e/support/bundle.tse2e/support/fixtures.tse2e/support/layout-cases.tse2e/support/layout-fixtures.tse2e/support/page.tse2e/support/x11.tse2e/tsconfig.jsonpackage.jsonpackages/hotkeys/src/_keyboard-event.tspackages/hotkeys/src/_match.tspackages/hotkeys/src/hotkey-recorder.tspackages/hotkeys/tests/alt-graph.test.tspnpm-workspace.yaml
Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.
-
📝 Walkthrough
-
AltGr handling now distinguishes character-producing input from unchanged keys. Windows unchanged-key AltGr presses normalize to Control+Alt. The pull request also adds browser and keyboard-layout end-to-end suites, their supporting setup, and CI workflows.
Changes: AltGr handling and end-to-end validation
Layer / File(s) Summary Normalize and test AltGr behavior
packages/hotkeys/src/_keyboard-event.ts,packages/hotkeys/src/_match.ts,packages/hotkeys/src/hotkey-recorder.ts,packages/hotkeys/tests/alt-graph.test.ts,docs/guides/sensible-defaults.md,.changeset/altgr-control-alt.mdWindows unchanged-key AltGr events normalize as Control+Alt. AltGr events that do not type a character do not match ordinary key bindings. Recorder handling uses normalized modifier state. Unit tests and the guide cover platform-specific behavior. Build browser test harness and cover hotkey behavior
e2e/support/*,e2e/browser/*,e2e/package.json,e2e/playwright.config.ts,e2e/tsconfig.json,e2e/eslint.config.js,.prettierignore,e2e/.gitignoreThe Playwright harness bundles the hotkeys page and exposes registration, focus, scope, held-key, and recorder controls. Browser tests cover chords, focus, sequences, scopes, held keys, and recording. Exercise keyboard layouts with X11
e2e/support/layout-*,e2e/support/x11.ts,e2e/layouts/*,e2e/docker/*,e2e/playwright.layouts.config.ts,e2e/scripts/layouts-docker.tsLayout fixtures configure X11 and send physical key combinations. Tests check AltGr and other layouts for binding matches, parsed keys, callback dispatch, and recording. Docker support runs layout tests with a virtual display. Run E2E suites in CI and document commands
.github/workflows/e2e.yml,package.json,pnpm-workspace.yaml,CONTRIBUTING.md,e2e/README.mdThe workspace and root scripts expose the E2E commands. CI runs browser and keyboard-layout jobs. Contributor and E2E documentation describe the suites and their commands. Priority: ⬇️ Low
Estimated code review effort: 4 (Complex) | ~45 minutes
Change: Bug fix
Suggested reviewers:
alemtuzlak
Merge Risk: ⚪ Minimal · up to
b0108-
The AltGr change is ready to merge after normal checks; no blocking issue was identified.
Pre-merge checks:
4 · 1-
Failed checks: 1 warningCheck name Status Explanation Resolution Docstring Coverage Docstring coverage is 61.90% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 21 functions across 20 files. (13 skipped… Write docstrings for the functions missing them to satisfy the coverage threshold. Passed checks: 4 passed-
Check name Status Explanation Title check The title is concise, specific, and accurately identifies the main change: preventing AltGr presses from firing unmodified hotkeys. Description check The description clearly explains the AltGr behavior changes, platform differences, testing scope, new E2E workspace, and CI workflow. It omits the template headings, checklist confirmations, and expli… Linked Issues check Check skipped because no linked issues were found for this pull request. Out of Scope Changes check Check skipped because no linked issues were found for this pull request. Full details: Description check
-
Explanation
The description clearly explains the AltGr behavior changes, platform differences, testing scope, new E2E workspace, and CI workflow. It omits the template headings, checklist confirmations, and explicit release-impact selection, but the main change and motivation are sufficiently documented.
-
Full details: Docstring Coverage
-
Explanation
Docstring coverage is 61.90% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 21 functions across 20 files. (13 skipped: 13 unsupported.)
Resolution
Write docstrings for the functions missing them to satisfy the coverage threshold.
-
- Fix all pre-merge checks with AI
✨ Finishing Touches: 💡 1
-
📝 Generate docstrings: 💡
-
- Commit to this branch
- Create a new PR
🧪 Generate unit tests (beta)
-
- Commit to this branch
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
A rabbit tests each key with care,
AltGr hops through the browser air.
X11 taps the layouts bright,
The CI burrow checks each byte.
Then carrots mark the green test light. Comment `@coderabbitai help` to get the list of available commands.-
AlemTuzlak approved these changes
KevinVandy merged thisdaecd95
KevinVandy closed this
Sign in to join this conversation.
🦋 Changeset detected#
Latest commit: b0108b3b092044c30fedd83b1a2a7abbfa5550e3
The changes in this PR will be included in the next version bump.
This PR includes changesets to release 18 packages
Not sure what this means? Click here to learn what changesets are.
Click here if you're a maintainer who wants to add another changeset to this PR