@devries-cameron20 / t3code-1 / commits / 664499c92e
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

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

Aditya Garud committed Aug 15, 2026 at 18:03 UTC 664499c92e838f36a0ff8187bc2cd95d7b8ef9d5
2 files changed +37 -2
apps/web/src/keybindings.test.ts
+29
@@ -728,6 +728,35 @@ describe("resolveShortcutCommand", () => {
728 "rightPanel.toggle",
729 );
730 });
731 +
732 + it("matches non-Latin layout letters using the physical key code", () => {
733 + const keybindings = compile([{ shortcut: modShortcut("d"), command: "diff.toggle" }]);
734 +
735 + assert.strictEqual(
736 + resolveShortcutCommand(event({ key: "в", code: "KeyD", metaKey: true }), keybindings, {
737 + platform: "MacIntel",
738 + }),
739 + "diff.toggle",
740 + );
741 + });
742 +
743 + it("ignores the physical key code when the layout types a different Latin letter", () => {
744 + const keybindings = compile([{ shortcut: modShortcut("d"), command: "diff.toggle" }]);
745 +
746 + // On a remapped layout the physical D key types "a"; only the physical
747 + // key whose layout output is "d" may trigger the shortcut.
748 + assert.isNull(
749 + resolveShortcutCommand(event({ key: "a", code: "KeyD", metaKey: true }), keybindings, {
750 + platform: "MacIntel",
751 + }),
752 + );
753 + assert.strictEqual(
754 + resolveShortcutCommand(event({ key: "d", code: "KeyL", metaKey: true }), keybindings, {
755 + platform: "MacIntel",
756 + }),
757 + "diff.toggle",
758 + );
759 + });
760 });
761
762 describe("formatShortcutLabel", () => {
apps/web/src/keybindings.ts
+8 -2
@@ -71,9 +71,15 @@ function normalizeEventKey(key: string): string {
71 }
72
73 function resolveEventKeys(event: ShortcutEventLike): Set<string> {
74 - const keys = new Set([normalizeEventKey(event.key)]);
74 + const layoutKey = normalizeEventKey(event.key);
75 + const keys = new Set([layoutKey]);
76 + // The physical-position fallback exists for layouts that type non-Latin
77 + // letters (Cyrillic, Greek) and for Option-modified symbols on macOS.
78 + // When the layout already produces a Latin letter, match on it alone;
79 + // otherwise a remapped physical key triggers shortcuts for two different
80 + // letters at once and shadows system shortcuts on non-QWERTY layouts.
81 const letterCode = event.code?.match(/^Key([A-Z])$/)?.[1];
76 - if (letterCode) {
82 + if (letterCode && !/^[a-z]$/.test(layoutKey)) {
83 keys.add(letterCode.toLowerCase());
84 }
85 const aliases = event.code ? EVENT_CODE_KEY_ALIASES[event.code] : undefined;