Skip to content
Source
Sign inSign up
TanStack/hotkeys

fix(hotkeys): Stop AltGr shortcuts from firing unmodified hotkeys #193

MergedKevinVandymerged 1 commit intomain fromrefs/pull/193/headmerged by KevinVandy

KevinVandycommented

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 Home or F.
  • On Windows, which reports AltGr as Control+Alt, those presses fire Control+Alt hotkeys instead, as in native Windows apps. Control+Alt+Home catches AltGr+Home, and the recorder records it as Mod+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 trigger Control+Alt hotkeys.
  • No public types change. The fix is in normalizeKeyboardEvent and the matcher, so matching, parseKeyboardEvent, and the recorder all agree.
  • New e2e/ workspace:
    • pnpm test:e2e runs Playwright tests for chords, inputs and focus, sequences, scopes, held keys, and the recorder in Chromium, Firefox, and WebKit.
    • pnpm test:e2e:layouts presses real keys through Linux keyboard layouts (AltGr, AZERTY, QWERTZ, Dvorak, Russian, dead keys) with Xvfb, setxkbmap, and xdotool. pnpm test:e2e:layouts:docker runs the same suite from macOS.
  • New E2E workflow 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 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
      NameType
      @tanstack/hotkeysPatch
      @tanstack/alpine-hotkeysPatch
      @tanstack/angular-hotkeysPatch
      @tanstack/ember-hotkeysPatch
      @tanstack/hotkeys-devtoolsPatch
      @tanstack/lit-hotkeysPatch
      @tanstack/octane-hotkeysPatch
      @tanstack/preact-hotkeysPatch
      @tanstack/react-hotkeysPatch
      @tanstack/solid-hotkeysPatch
      @tanstack/svelte-hotkeysPatch
      @tanstack/vue-hotkeysPatch
      @tanstack/angular-hotkeys-devtoolsPatch
      @tanstack/preact-hotkeys-devtoolsPatch
      @tanstack/react-hotkeys-devtoolsPatch
      @tanstack/solid-hotkeys-devtoolsPatch
      @tanstack/svelte-hotkeys-devtoolsPatch
      @tanstack/vue-hotkeys-devtoolsPatch

      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

    2. 🚀 Changeset Version Preview

      1 package(s) bumped directly, 17 bumped as dependents.

      🟩 Patch bumps

      PackageVersionReason
      @tanstack/hotkeys0.16.0 → 0.16.1Changeset
      @tanstack/alpine-hotkeys0.4.0 → 0.4.1Dependent
      @tanstack/angular-hotkeys0.15.0 → 0.15.1Dependent
      @tanstack/angular-hotkeys-devtools0.2.8 → 0.2.9Dependent
      @tanstack/ember-hotkeys0.4.0 → 0.4.1Dependent
      @tanstack/hotkeys-devtools1.4.0 → 1.4.1Dependent
      @tanstack/lit-hotkeys0.16.0 → 0.16.1Dependent
      @tanstack/octane-hotkeys0.5.0 → 0.5.1Dependent
      @tanstack/preact-hotkeys0.15.0 → 0.15.1Dependent
      @tanstack/preact-hotkeys-devtools0.10.8 → 0.10.9Dependent
      @tanstack/react-hotkeys0.15.0 → 0.15.1Dependent
      @tanstack/react-hotkeys-devtools0.10.8 → 0.10.9Dependent
      @tanstack/solid-hotkeys0.15.0 → 0.15.1Dependent
      @tanstack/solid-hotkeys-devtools0.10.8 → 0.10.9Dependent
      @tanstack/svelte-hotkeys0.15.0 → 0.15.1Dependent
      @tanstack/svelte-hotkeys-devtools0.2.8 → 0.2.9Dependent
      @tanstack/vue-hotkeys0.15.0 → 0.15.1Dependent
      @tanstack/vue-hotkeys-devtools0.10.8 → 0.10.9Dependent
    3. Review the following changes in direct dependencies. Learn more about Socket for GitHub.

      Diff Package Supply Chain
      Security
      Vulnerability Quality Maintenance License
      Added@​playwright/​test@​1.63.010010010099100

      View full report

    4. Open in StackBlitz

      @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@193

      commit: b0108b3

    5. coderabbitai[bot](GitHub profile, opens in a new tab)commented
      Review in Change Stack →

      No 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.md is excluded by !docs/**/reference/**
      • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml, !**/pnpm-lock.yaml
      📒 Files selected for processing: 33
      • .changeset/altgr-control-alt.md
      • .github/workflows/e2e.yml
      • .prettierignore
      • CONTRIBUTING.md
      • docs/guides/sensible-defaults.md
      • e2e/.gitignore
      • e2e/README.md
      • e2e/browser/chords.spec.ts
      • e2e/browser/focus.spec.ts
      • e2e/browser/held-keys-and-recorder.spec.ts
      • e2e/browser/sequences-and-scopes.spec.ts
      • e2e/docker/Dockerfile
      • e2e/docker/tanstack.xkb
      • e2e/eslint.config.js
      • e2e/layouts/alt-graph.spec.ts
      • e2e/layouts/layouts.spec.ts
      • e2e/package.json
      • e2e/playwright.config.ts
      • e2e/playwright.layouts.config.ts
      • e2e/scripts/layouts-docker.ts
      • e2e/support/bundle.ts
      • e2e/support/fixtures.ts
      • e2e/support/layout-cases.ts
      • e2e/support/layout-fixtures.ts
      • e2e/support/page.ts
      • e2e/support/x11.ts
      • e2e/tsconfig.json
      • package.json
      • packages/hotkeys/src/_keyboard-event.ts
      • packages/hotkeys/src/_match.ts
      • packages/hotkeys/src/hotkey-recorder.ts
      • packages/hotkeys/tests/alt-graph.test.ts
      • pnpm-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.md
      Windows 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/.gitignore
      The 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.ts
      Layout 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.md
      The 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: Passed 4 · Failed 1
      Failed Failed checks: 1 warning
      Check nameStatusExplanationResolution
      Docstring CoverageWarningDocstring 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 Passed checks: 4 passed
      Check nameStatusExplanation
      Title checkPassedThe title is concise, specific, and accurately identifies the main change: preventing AltGr presses from firing unmodified hotkeys.
      Description checkPassedThe 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 checkPassedCheck skipped because no linked issues were found for this pull request.
      Out of Scope Changes checkPassedCheck 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.

      ❤️ Share
      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.
    6. AlemTuzlak approved these changes

    7. KevinVandy merged thisdaecd95

    8. KevinVandy closed this

Sign in to join this conversation.