Skip to content

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

Open
yashranaway wants to merge 1 commit into
pingdotgg:mainfrom
yashranaway:layout-key-shortcuts
Open

Limit physical key fallback to non-Latin layout output#4469
yashranaway wants to merge 1 commit into
pingdotgg:mainfrom
yashranaway:layout-key-shortcuts

Conversation

@yashranaway

@yashranaway yashranaway commented Jul 24, 2026

Copy link
Copy Markdown

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
Small, targeted change to keyboard shortcut matching with explicit tests; no auth, data, or API surface changes.

Overview
Shortcut resolution no longer treats physical KeyAKeyZ position as an alternate match when the keyboard layout already produces a Latin letter.

resolveEventKeys still falls back to the physical letter for non-Latin layout output (e.g. Cyrillic) and Option-modified symbols on macOS, where event.key is not a single Latin letter. On remapped Latin layouts, matching uses layout output only, so one keypress cannot satisfy two different letter bindings (e.g. physical D typing a no longer fires mod+D).

Regression tests cover non-Latin layout matching by position and remapped Latin layouts ignoring physical code when layout key differs.

Reviewed by Cursor Bugbot for commit dc1345e. Bugbot is set up for automated code reviews on this repo. Configure here.

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 dc1345e.

Shortcut matching accepted both the layout-derived key and the physical
KeyA-KeyZ position for every keypress. On remapped Latin layouts one
physical key then triggered shortcuts for two different letters, and a
shortcut like mod+D consumed the key a user needs for mod+A.

Keep the physical fallback only when the layout produces something other
than a Latin letter, which is the case it was added for: non-Latin
layouts and Option-modified symbols on macOS.

Fixes pingdotgg#4434
@coderabbitai

coderabbitai Bot commented Jul 24, 2026

Copy link
Copy Markdown

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: 04f1f9db-1fde-4d0a-9f4f-5ffd6dd1b6fb

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.

@github-actions github-actions Bot added vouch:unvouched PR author is not yet trusted in the VOUCHED list. size:S 10-29 changed lines (additions + deletions). labels Jul 24, 2026
@macroscopeapp

macroscopeapp Bot commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

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.

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

Labels

size:S 10-29 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Keyboard shortcuts react to both physical and layout-derived keys

1 participant