parent
9988471fb8
commit
10bc7e948c
|
@ -39,15 +39,16 @@ export class KeyEventsPlugin extends EventManagerPlugin {
|
|||
}
|
||||
|
||||
static parseEventName(eventName: string) /* {'domEventName': string, 'fullKey': string} */ {
|
||||
eventName = eventName.toLowerCase();
|
||||
var parts = eventName.split('.');
|
||||
var parts = eventName.toLowerCase().split('.');
|
||||
|
||||
var domEventName = ListWrapper.removeAt(parts, 0);
|
||||
if ((parts.length === 0) ||
|
||||
!(StringWrapper.equals(domEventName, 'keydown') ||
|
||||
StringWrapper.equals(domEventName, 'keyup'))) {
|
||||
return null;
|
||||
}
|
||||
var key = ListWrapper.removeLast(parts);
|
||||
|
||||
var key = KeyEventsPlugin._normalizeKey(ListWrapper.removeLast(parts));
|
||||
|
||||
var fullKey = '';
|
||||
ListWrapper.forEach(modifierKeys, (modifierName) => {
|
||||
|
@ -94,4 +95,14 @@ export class KeyEventsPlugin extends EventManagerPlugin {
|
|||
}
|
||||
};
|
||||
}
|
||||
|
||||
static _normalizeKey(keyName: string): string {
|
||||
// TODO: switch to a StringMap if the mapping grows too much
|
||||
switch (keyName) {
|
||||
case 'esc':
|
||||
return 'escape';
|
||||
default:
|
||||
return keyName;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -65,5 +65,10 @@ export function main() {
|
|||
|
||||
});
|
||||
|
||||
it('should alias esc to escape', () => {
|
||||
expect(KeyEventsPlugin.parseEventName('keyup.control.esc'))
|
||||
.toEqual(KeyEventsPlugin.parseEventName('keyup.control.escape'));
|
||||
});
|
||||
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue