File tree Expand file tree Collapse file tree 2 files changed +19
-3
lines changed Expand file tree Collapse file tree 2 files changed +19
-3
lines changed Original file line number Diff line number Diff line change @@ -39,15 +39,16 @@ export class KeyEventsPlugin extends EventManagerPlugin {
3939 }
4040
4141 static parseEventName ( eventName : string ) /* {'domEventName': string, 'fullKey': string} */ {
42- eventName = eventName . toLowerCase ( ) ;
43- var parts = eventName . split ( '.' ) ;
42+ var parts = eventName . toLowerCase ( ) . split ( '.' ) ;
43+
4444 var domEventName = ListWrapper . removeAt ( parts , 0 ) ;
4545 if ( ( parts . length === 0 ) ||
4646 ! ( StringWrapper . equals ( domEventName , 'keydown' ) ||
4747 StringWrapper . equals ( domEventName , 'keyup' ) ) ) {
4848 return null ;
4949 }
50- var key = ListWrapper . removeLast ( parts ) ;
50+
51+ var key = KeyEventsPlugin . _normalizeKey ( ListWrapper . removeLast ( parts ) ) ;
5152
5253 var fullKey = '' ;
5354 ListWrapper . forEach ( modifierKeys , ( modifierName ) => {
@@ -94,4 +95,14 @@ export class KeyEventsPlugin extends EventManagerPlugin {
9495 }
9596 } ;
9697}
98+
99+ static _normalizeKey ( keyName : string ) : string {
100+ // TODO: switch to a StringMap if the mapping grows too much
101+ switch ( keyName ) {
102+ case 'esc' :
103+ return 'escape' ;
104+ default :
105+ return keyName ;
106+ }
107+ }
97108}
Original file line number Diff line number Diff line change @@ -65,5 +65,10 @@ export function main() {
6565
6666 } ) ;
6767
68+ it ( 'should alias esc to escape' , ( ) => {
69+ expect ( KeyEventsPlugin . parseEventName ( 'keyup.control.esc' ) )
70+ . toEqual ( KeyEventsPlugin . parseEventName ( 'keyup.control.escape' ) ) ;
71+ } ) ;
72+
6873 } ) ;
6974}
You can’t perform that action at this time.
0 commit comments