Skip to content
Source
Sign inSign up
pingdotgg/t3code

Limit physical key fallback to non-Latin layout output #4469

Mergedyashranaway(GitHub profile, opens in a new tab)merged 1 commit intomain fromrefs/pull/4469/headmerged by juliusmarminge View on GitHub

What Changed

Shortcut matching only falls back to the physical KeyA-KeyZ position when the layout-derived key is not itself a Latin letter. Two regression tests cover a non-Latin layout (still matched by position) and a remapped Latin layout (matched by layout output only).

Why

resolveEventKeys accepted both the layout key and the physical code for every keypress. On a remapped Latin layout one physical key then triggered shortcuts for two different letters at once: with a layout where physical D types "a", a mod+D binding fires on mod+A and the user can no longer select all text.

The physical fallback exists for a real reason (Cyrillic and other non-Latin layouts, plus Option-modified symbols on macOS, produce keys that ASCII-defined shortcuts can never match), so it stays for exactly those cases: when event.key is not a Latin letter. When the layout already types Latin letters it speaks the shortcut vocabulary and is trusted alone.

Fixes #4434

Testing

  • vp test run apps/web/src/keybindings.test.ts passes (43/43), including the existing Option-modified KeyB case and the two new layout tests
  • Related suites (shortcutModifierState, KeybindingsSettings.logic, projectScriptKeybindings) pass (17/17)
  • pnpm typecheck in apps/web clean
  • vp lint on changed files clean

Checklist

  • This PR is small and focused
  • I explained what changed and why
  • I included before/after screenshots for any UI changes
  • I included a video for animation/interaction changes

Note

Low Risk Localized change to shortcut resolution with targeted tests; behavior shift only affects remapped Latin layouts where layout and physical labels disagreed.

Overview Keyboard shortcuts no longer treat physical KeyA–KeyZ position as an extra match when the layout already types a Latin letter.

resolveEventKeys still falls back to event.code for non-Latin output (e.g. Cyrillic) and macOS Option symbols, but remapped Latin layouts (physical D typing a) only match on the layout character—so mod+D no longer fires on mod+A and system shortcuts like select-all are not shadowed.

Two tests cover Cyrillic-on-physical-D still resolving diff.toggle, and remapped Latin keys matching by layout output only.

Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 85645a8b62f7f2666617aae80448168e4ce8ae6d. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).

Note

Limit physical key code fallback in resolveEventKeys to non-Latin layout output

Previously, resolveEventKeys always added the physical letter derived from event.code as a fallback candidate, which caused shortcuts to fire incorrectly when the keyboard layout produced a different Latin letter than the physical key label (e.g. key 'a' on a key with code KeyD would match a binding for 'd').

  • The fallback to the physical key letter is now only applied when the layout key is not a Latin a–z character, so non-Latin layouts (e.g. Cyrillic) still resolve shortcuts correctly via physical key.
  • Latin layouts that remap keys (e.g. Dvorak-style remapping) no longer trigger shortcuts for the wrong key.
  • Behavioral Change: events where the layout produces a Latin letter but on a physically different key will no longer match bindings for the physical key's label.
Macroscope summarized 85645a8.
    1. coderabbitai[bot](GitHub profile, opens in a new tab)commented

      Important

      Review skipped

      Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

      ⚙️ Run configuration

      Configuration used: Repository UI

      Review profile: CHILL

      Plan: Pro Plus

      Run ID: c9f01ff5-d076-453e-ab16-df23466324ac

      You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

      Use the checkbox below for a quick retry:

      • 🔍 Trigger review
      ✨ Finishing Touches
      🧪 Generate unit tests (beta)
      • Create PR with unit tests

      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
      Comment `@coderabbitai help` to get the list of available commands.
    2. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched

    3. Approvability

      Verdict: Approved

      Straightforward bug fix adding a regex guard to prevent physical key fallback when the layout already outputs a Latin letter. Change is well-scoped, clearly documented, and includes tests covering both the fix and preserved behavior for non-Latin layouts.

      You can customize Macroscope's approvability policy. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    4. juliusmarminge merged this664499c

    5. juliusmarminge closed this

Sign in to join this conversation.