Skip to content

Commit 5b10084

Browse files
Correct comment & add tests
1 parent 066c216 commit 5b10084

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

packages/core/src/components/hotkeys/hotkeyParser.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,9 @@ export const CONFIG_ALIASES: KeyMap = {
6363
};
6464

6565
/**
66-
* Key mapping used in getKeyCombo() implementation for physical keys which are not alphabet characters or digits.
67-
*
68-
* N.B. at some point, we should stop using this mapping, since we can implement the desired functionality in a more
69-
* straightforward way by using the `event.code` property, which will always tell us the identifiers represented by the
70-
* _values_ in this object (the default physical keys, unaltered by modifier keys or keyboard layout).
66+
* Key mapping used in getKeyCombo() implementation to normalize shifted character keys.
67+
* Maps shifted characters (e.g., "!") to their unshifted equivalents (e.g., "1") so that
68+
* "!" and "shift+1" are treated as the same hotkey combo.
7169
*/
7270
export const SHIFT_KEYS: KeyMap = {
7371
"~": "`",

packages/core/test/hotkeys/hotkeysParserTests.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,13 @@ describe("HotkeysParser", () => {
137137
tests.push(makeComboTest("alt + a", { altKey: true, code: "KeyA", key: "a" }));
138138
verifyCombos(tests);
139139
});
140+
141+
it("handles alt modifier with special characters (macOS)", () => {
142+
// On macOS, Alt+C produces "ç" - we should fall back to code-based matching
143+
const tests = [] as ComboTest[];
144+
tests.push(makeComboTest("alt + c", { altKey: true, code: "KeyC", key: "ç" }));
145+
verifyCombos(tests, false); // don't verify string combos since key is "ç" not "c"
146+
});
140147
});
141148

142149
describe("parseKeyCombo", () => {

0 commit comments

Comments
 (0)