Skip to content

Commit b575659

Browse files
fix(web): preserve physical Alt shortcut recording
1 parent 68fe057 commit b575659

2 files changed

Lines changed: 22 additions & 8 deletions

File tree

‎apps/web/src/components/settings/KeybindingsSettings.logic.test.ts‎

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -211,17 +211,31 @@ describe("KeybindingsSettings.logic", () => {
211211
).toBe(expected);
212212
});
213213

214-
it("records German punctuation that triggers the saved binding while default recording stays physical", () => {
215-
for (const { key, shiftKey, expected, defaultInput } of [
216-
{ key: "#", shiftKey: false, expected: "#", defaultInput: "\\" },
217-
{ key: "'", shiftKey: true, expected: "shift+'", defaultInput: "shift+\\" },
214+
it("records layout punctuation while preserving physical Alt shortcuts; saved bindings still trigger", () => {
215+
for (const { key, code, altKey = false, shiftKey, expected, defaultInput } of [
216+
{ key: "#", code: "Backslash", shiftKey: false, expected: "#", defaultInput: "\\" },
217+
{
218+
key: "'",
219+
code: "Backslash",
220+
shiftKey: true,
221+
expected: "shift+'",
222+
defaultInput: "shift+\\",
223+
},
224+
{
225+
key: "¡",
226+
code: "Digit1",
227+
altKey: true,
228+
shiftKey: false,
229+
expected: "alt+1",
230+
defaultInput: "alt+1",
231+
},
218232
]) {
219233
const pressed = {
220234
key,
221-
code: "Backslash",
235+
code,
222236
metaKey: false,
223237
ctrlKey: false,
224-
altKey: false,
238+
altKey,
225239
shiftKey,
226240
};
227241
expect(keybindingFromKeyboardEvent(pressed, "MacIntel")).toBe(defaultInput);

‎apps/web/src/components/settings/KeybindingsSettings.logic.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -388,11 +388,11 @@ function titleCaseCommandSegment(segment: string): string {
388388
}
389389

390390
function recordedLayoutShortcutKey(
391-
event: Pick<KeyboardEvent, "key" | "code" | "shiftKey">,
391+
event: Pick<KeyboardEvent, "key" | "code" | "shiftKey" | "altKey">,
392392
): string {
393393
const physicalKey = shortcutKeyFromEvent(event);
394394
const layoutKey = event.key.toLowerCase();
395-
if (layoutKey.length !== 1) return physicalKey;
395+
if (event.altKey || layoutKey.length !== 1) return physicalKey;
396396
// Normalize only US shifted glyphs at their US position. Other layouts can
397397
// produce the same glyph without Shift or at a different position.
398398
const unshiftedKey = event.shiftKey ? US_SHIFTED_TO_UNSHIFTED_KEYS.get(layoutKey) : undefined;

0 commit comments

Comments
 (0)