parent
9988471fb8
commit
10bc7e948c
|
@ -39,15 +39,16 @@ export class KeyEventsPlugin extends EventManagerPlugin {
|
||||||
}
|
}
|
||||||
|
|
||||||
static parseEventName(eventName: string) /* {'domEventName': string, 'fullKey': string} */ {
|
static parseEventName(eventName: string) /* {'domEventName': string, 'fullKey': string} */ {
|
||||||
eventName = eventName.toLowerCase();
|
var parts = eventName.toLowerCase().split('.');
|
||||||
var parts = eventName.split('.');
|
|
||||||
var domEventName = ListWrapper.removeAt(parts, 0);
|
var domEventName = ListWrapper.removeAt(parts, 0);
|
||||||
if ((parts.length === 0) ||
|
if ((parts.length === 0) ||
|
||||||
!(StringWrapper.equals(domEventName, 'keydown') ||
|
!(StringWrapper.equals(domEventName, 'keydown') ||
|
||||||
StringWrapper.equals(domEventName, 'keyup'))) {
|
StringWrapper.equals(domEventName, 'keyup'))) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
var key = ListWrapper.removeLast(parts);
|
|
||||||
|
var key = KeyEventsPlugin._normalizeKey(ListWrapper.removeLast(parts));
|
||||||
|
|
||||||
var fullKey = '';
|
var fullKey = '';
|
||||||
ListWrapper.forEach(modifierKeys, (modifierName) => {
|
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