File tree Expand file tree Collapse file tree 1 file changed +13
-1
lines changed
apps/sim/app/workspace/[workspaceId]/providers Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Original file line number Diff line number Diff 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+
6071function 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 &&
You can’t perform that action at this time.
0 commit comments