@@ -14,6 +14,32 @@ interface ShortcutBinding {
1414// Store all active shortcut bindings for management
1515const activeBindings : Map < string , ShortcutBinding [ ] > = new Map ( ) ;
1616
17+ // Handle special key mappings and aliases
18+ const keyMap : { [ key : string ] : string [ ] } = {
19+ 'return' : [ 'Enter' ] ,
20+ 'enter' : [ 'Enter' ] , // alias for return
21+ 'del' : [ 'Delete' ] ,
22+ 'delete' : [ 'Delete' ] , // alias for del
23+ 'esc' : [ 'Escape' ] ,
24+ 'escape' : [ 'Escape' ] , // alias for esc
25+ 'space' : [ ' ' , 'Space' ] ,
26+ 'tab' : [ 'Tab' ] ,
27+ 'backspace' : [ 'Backspace' ] ,
28+ 'home' : [ 'Home' ] ,
29+ 'end' : [ 'End' ] ,
30+ 'pageup' : [ 'PageUp' ] ,
31+ 'pagedown' : [ 'PageDown' ] ,
32+ 'up' : [ 'ArrowUp' ] ,
33+ 'down' : [ 'ArrowDown' ] ,
34+ 'left' : [ 'ArrowLeft' ] ,
35+ 'right' : [ 'ArrowRight' ]
36+ } ;
37+
38+ // Function keys
39+ for ( let i = 1 ; i <= 19 ; i ++ ) {
40+ keyMap [ `f${ i } ` ] = [ `F${ i } ` ] ;
41+ }
42+
1743function removeGlobalShortcut ( namespace : string ) {
1844 bindGlobalShortcut ( "" , null , namespace ) ;
1945}
@@ -124,32 +150,6 @@ export function keyMatches(e: KeyboardEvent, key: string): boolean {
124150 return false ;
125151 }
126152
127- // Handle special key mappings and aliases
128- const keyMap : { [ key : string ] : string [ ] } = {
129- 'return' : [ 'Enter' ] ,
130- 'enter' : [ 'Enter' ] , // alias for return
131- 'del' : [ 'Delete' ] ,
132- 'delete' : [ 'Delete' ] , // alias for del
133- 'esc' : [ 'Escape' ] ,
134- 'escape' : [ 'Escape' ] , // alias for esc
135- 'space' : [ ' ' , 'Space' ] ,
136- 'tab' : [ 'Tab' ] ,
137- 'backspace' : [ 'Backspace' ] ,
138- 'home' : [ 'Home' ] ,
139- 'end' : [ 'End' ] ,
140- 'pageup' : [ 'PageUp' ] ,
141- 'pagedown' : [ 'PageDown' ] ,
142- 'up' : [ 'ArrowUp' ] ,
143- 'down' : [ 'ArrowDown' ] ,
144- 'left' : [ 'ArrowLeft' ] ,
145- 'right' : [ 'ArrowRight' ]
146- } ;
147-
148- // Function keys
149- for ( let i = 1 ; i <= 19 ; i ++ ) {
150- keyMap [ `f${ i } ` ] = [ `F${ i } ` ] ;
151- }
152-
153153 const mappedKeys = keyMap [ key . toLowerCase ( ) ] ;
154154 if ( mappedKeys ) {
155155 return mappedKeys . includes ( e . key ) || mappedKeys . includes ( e . code ) ;
@@ -163,7 +163,7 @@ export function keyMatches(e: KeyboardEvent, key: string): boolean {
163163
164164 // For letter keys, use the physical key code for consistency
165165 if ( key . length === 1 && key >= 'a' && key <= 'z' ) {
166- return e . code === `Key ${ key . toUpperCase ( ) } ` ;
166+ return e . key . toLowerCase ( ) === key . toLowerCase ( ) ;
167167 }
168168
169169 // For regular keys, check both key and code as fallback
0 commit comments