Skip to content

Commit 3fad92b

Browse files
committed
fix(hotkeys): fall back to event.code for international keyboard layout compatibility
1 parent 4f705d7 commit 3fad92b

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

apps/sim/app/workspace/[workspaceId]/providers/global-commands-provider.tsx

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,26 @@ function parseShortcut(shortcut: string): ParsedShortcut {
5757
}
5858
}
5959

60+
/**
61+
* Maps a KeyboardEvent.code value to the logical key name used in shortcut definitions.
62+
* Needed for international keyboard layouts where e.key may produce unexpected characters
63+
* (e.g. macOS Option+letter yields 'å' instead of 'a', dead keys yield 'Dead').
64+
*/
65+
function codeToKey(code: string): string | undefined {
66+
if (code.startsWith('Key')) return code.slice(3).toLowerCase()
67+
if (code.startsWith('Digit')) return code.slice(5)
68+
return undefined
69+
}
70+
6071
function matchesShortcut(e: KeyboardEvent, parsed: ParsedShortcut): boolean {
6172
const isMac = isMacPlatform()
6273
const expectedCtrl = parsed.ctrl || (parsed.mod ? !isMac : false)
6374
const expectedMeta = parsed.meta || (parsed.mod ? isMac : false)
6475
const eventKey = e.key.length === 1 ? e.key.toLowerCase() : e.key
76+
const keyMatches = eventKey === parsed.key || codeToKey(e.code) === parsed.key
6577

6678
return (
67-
eventKey === parsed.key &&
79+
keyMatches &&
6880
!!e.ctrlKey === !!expectedCtrl &&
6981
!!e.metaKey === !!expectedMeta &&
7082
!!e.shiftKey === !!parsed.shift &&

0 commit comments

Comments
 (0)