Skip to content

Commit c7480cb

Browse files
fix(web): keep physical matching for Alt chords on a layout +
A German alt+] binding recorded on the + key must still match. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent a0fbcd8 commit c7480cb

2 files changed

Lines changed: 17 additions & 3 deletions

File tree

‎apps/web/src/keybindings.test.ts‎

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -659,7 +659,7 @@ describe("resolveShortcutCommand", () => {
659659
);
660660
});
661661

662-
it("treats mod and an unshifted layout + as zoom, not its physical key", () => {
662+
it('leaves Ctrl+layout "+" to zoom, except on the number row or with Alt', () => {
663663
assert.isNull(
664664
resolveShortcutCommand(
665665
event({ key: "+", code: "BracketRight", ctrlKey: true }),
@@ -683,6 +683,19 @@ describe("resolveShortcutCommand", () => {
683683
),
684684
"thread.jump.1",
685685
);
686+
assert.strictEqual(
687+
resolveShortcutCommand(
688+
event({ key: "+", code: "BracketRight", altKey: true }),
689+
compile([
690+
{
691+
shortcut: modShortcut("]", { modKey: false, altKey: true }),
692+
command: "terminal.toggle",
693+
},
694+
]),
695+
{ platform: "Linux" },
696+
),
697+
"terminal.toggle",
698+
);
686699
});
687700

688701
it("does not let a punctuation position shadow a Latin layout key", () => {

‎packages/shared/src/keybindings.ts‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,12 +88,13 @@ export function normalizeEventKey(key: string): string {
8888
}
8989

9090
export function shortcutKeyFromEvent(
91-
event: Pick<ShortcutEventLike, "key" | "code" | "shiftKey">,
91+
event: Pick<ShortcutEventLike, "key" | "code" | "shiftKey" | "altKey">,
9292
): string {
9393
const layoutKey = normalizeEventKey(event.key);
9494
if (/^[a-z]$/.test(layoutKey)) return layoutKey;
9595
// An unshifted "+" is a dedicated zoom key (German, Spanish, Nordic); Czech types it on Digit1.
96-
if (layoutKey === "+" && !event.shiftKey && !event.code?.startsWith("Digit")) return layoutKey;
96+
const isZoomPlus = layoutKey === "+" && !event.shiftKey && !event.altKey;
97+
if (isZoomPlus && !event.code?.startsWith("Digit")) return layoutKey;
9798
const physicalKey = event.code ? EVENT_CODE_SHORTCUT_KEYS[event.code] : undefined;
9899
return physicalKey ?? layoutKey;
99100
}

0 commit comments

Comments
 (0)