Skip to content

Match shortcuts by physical key on non-Latin keyboard layouts - #7786

Merged
ymichael merged 1 commit into
mainfrom
bb/3967-keyboard-shortcuts-do-not-fire-on-non-latin-thr_tnbpyt5tu8
Nov 18, 2026
Merged

ymichael merged 1 commit into
mainfrom
bb/3967-keyboard-shortcuts-do-not-fire-on-non-latin-thr_tnbpyt5tu8

Conversation

@ymichael

@ymichael ymichael commented Nov 18, 2026 •

Copy link
Copy Markdown
Collaborator

Human comments

What was wrong

normalizeAppShortcutInputKey (packages/domain/src/app-keybindings.ts) compares the layout-dependent KeyboardEvent.key with the binding's Latin key. It falls back to the physical event.code only when Alt is held. On a Cyrillic, Greek, Hebrew or Arabic layout the K key reports key: "л" / "κ" / "ל" / "ن", and "л" !== "k". So Mod+K, Mod+Shift+P, Mod+, and every other letter shortcut did nothing, and so did app commands, plugin commands and embedded-browser shortcuts. Several call sites also did their own event.key.toLowerCase() === "v" style checks: the composer's paste-as-plain-text check, Prompt Library's Mod+S, the Tasks plugin's c / s / p / digit keys and the desktop Cmd+R reload. They had the same bug. Recording a shortcut on such a layout also saved "л". #3967 has the full analysis.

What changed

  • One key comparison. normalizeAppShortcutInputKey now uses the physical key whenever the typed character is a single non-Latin letter or digit (\p{L}|\p{N}, not \p{Script=Latin}, not ASCII 0–9). This covers Key*, Digit*, and the punctuation positions ([ ] , . ; ' \ - = \ /`), so Russian Mod+Shift+Х fires Mod+Shift+[ and Mod+Б fires Mod+,. The Alt path is unchanged, apart from also resolving those punctuation positions.

    • Latin layouts (Dvorak, Colemak, AZERTY, QWERTZ incl. ü, Turkish ı) still match by the typed character.
    • A new matchesAppShortcutKey(input, key) also accepts the typed character when Alt is up. Overrides a user saved under a non-Latin character ({ key: "л" }, the only workaround so far) keep working.
    • matchesAppShortcut is built on it, so app commands, plugin commands, the desktop embedded browser, conflict detection and shortcut recording (which now records k) all use one rule.
  • Every hand-rolled check routes through it:

    • the composer's Mod+Shift+V (paste as plain text)
    • Prompt Library's Mod+S
    • the Tasks plugin's c, row s/p and the status/priority digit menus
    • the desktop reload shortcut (desktop-reload-shortcut.ts now reads Electron's input.code)
    • terminal copy/paste, which had its own KeyC/KeyV fallback

    Modifier handling at each site is unchanged.

  • Plugin SDK. Composer, Prompt Library and Tasks are forkable and cannot import @bb/domain. They call the new experimental_matchesShortcutKey(event, key) from @get-bb/plugin-sdk/app, which is the domain function itself, both in the app runtime and in the test runtime. The PR includes:

    • the docs/api_to_audit.md entry
    • the Plugin Guide surface listing
    • a plugin-authoring doc note
    • the SDK bump to 0.6.160, and engines.bbPluginSdk >= 0.6.160 for the three plugins
  • Deviation from the issue's prototype branch: it replaced the typed character outright. This PR also keeps matching the typed character (without Alt), so saved non-Latin overrides are not silently broken. It also restricts the fallback to non-Latin scripts rather than all non-ASCII characters, so ü/é/ı on Latin layouts are untouched.

  • No wire changes.

Credit: T3 Code fixed the same class in pingdotgg/t3code#21508 (launcher letters on non-Latin layouts) and pingdotgg/t3code#28470 (paste-as-text shortcut on non-Latin layouts), which pointed at the composer site. pingdotgg/t3code#26408 is the related layout-specific zoom fix.

How you verified

Real-browser repro (before/after). Ran pnpm start:worktree and sent trusted keydowns through CDP Input.dispatchKeyEvent with each layout's real key/code pair (macOS, so Mod = Cmd):

Keypress origin/main 02264cf this branch
English Cmd+K (k/KeyK) Quick palette opens Quick palette opens
Russian Cmd+K (л/KeyK) nothing Quick palette opens
Russian Cmd+Shift+P (З/KeyP) nothing Quick palette opens
Greek Cmd+K (κ/KeyK) nothing Quick palette opens
Russian Cmd+, (б/Comma) nothing navigates to /settings
Dvorak Cmd+K (k/KeyV) Quick palette opens Quick palette opens
Dvorak Cmd+. (./KeyE) nothing nothing

In the built app, __bbPluginRuntime.pluginSdkApp.experimental_matchesShortcutKey returns true for (л/KeyK, "k") and for (М/KeyV + Shift, "v"), and false for Dvorak (k/KeyV, "v").

Tests.

  • packages/domain/test/app-keybindings-layouts.test.ts: per-layout table covering US, Russian, Ukrainian, Greek, Hebrew, Arabic (incl. Arabic-Indic digits), Dvorak, Colemak, AZERTY, QWERTZ and Turkish. It also covers Mod+Shift+[ from Х, saved non-Latin overrides, Windows AltGr text (Polish ą, German @, Serbian ђ with Ctrl+Alt) not firing Ctrl/Alt shortcuts, and macOS Option compositions. Against origin/main's app-keybindings.ts, 16 of these fail; the Latin and AltGr controls pass on both.
  • Composer: Ctrl+Shift+М keeps a pasted thread URL literal (PromptBoxInternal.test.tsx).
  • Recording on a Russian layout saves k (keyboard-shortcut-settings.test.ts).
  • Desktop reload from к/ρ on KeyR and Dvorak r; a Latin p on KeyR does not reload.

Turbo runs:

  • pnpm exec turbo run typecheck lint --filter=@bb/domain --filter=@bb/app --filter=@bb/desktop --filter=@get-bb/plugin-sdk --filter=bb-plugin-bb--composer --filter=bb-plugin-bb--prompt-library --filter=bb-plugin-tasks --filter=bb-plugin-plugin-api-docs: 19/19.
  • pnpm exec turbo run test on @bb/domain, @bb/desktop, @bb/server, @bb/app, the plugin SDK, composer, prompt-library, tasks, plugin-api-docs and bb-guide: all green except two load timeouts under the parallel run, both green when rerun alone:
    • kill-processes.test.ts
    • CommandPalette.test.tsx (a lazy-import timeout that cascaded)

Not covered: Settings still labels shortcuts with the Latin key (e.g. "Ctrl + ,") on a Cyrillic layout. Showing the active layout's characters would need navigator.keyboard.getLayoutMap(); this is listed as an open question in the audit entry.

Fixes #3967

🤖 Generated with Claude Code

AGENT GENERATED

On Cyrillic, Greek, Hebrew and Arabic layouts KeyboardEvent.key is the
layout character ("л" for the K key), so normalizeAppShortcutInputKey only
fell back to event.code when Alt was held and every letter shortcut was
dead. It now uses the physical key whenever the typed character is a
non-Latin letter or digit, including punctuation positions such as [ ] and
the comma. Latin layouts (Dvorak, Colemak, AZERTY, QWERTZ) keep matching by
the typed character, the Alt path is unchanged, and shortcuts saved under a
non-Latin character still match.

matchesAppShortcutKey is the single key comparison. The composer's
paste-as-plain-text check, Prompt Library's Mod+S, the Tasks plugin's
single-key shortcuts, the desktop reload shortcut and terminal copy/paste now
use it; forkable plugins reach it through experimental_matchesShortcutKey.

Fixes #3967

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ymichael
ymichael force-pushed the bb/3967-keyboard-shortcuts-do-not-fire-on-non-latin-thr_tnbpyt5tu8 branch from e4cd184 to 181d1b3 Compare November 18, 2026 21:47
@ymichael
ymichael merged commit cb14a40 into main Nov 18, 2026
53 checks passed
@ymichael
ymichael deleted the bb/3967-keyboard-shortcuts-do-not-fire-on-non-latin-thr_tnbpyt5tu8 branch November 18, 2026 21:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Keyboard shortcuts do not fire on non-latin layouts: key matching compares the layout character, not the physical key

1 participant