update components

This commit is contained in:
Luke Pulverenti 2016-04-02 12:15:48 -04:00
parent cc555065f7
commit c3fd6c022f
54 changed files with 296 additions and 87 deletions

View file

@ -90,6 +90,13 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
*/
var SPACE_KEY = /^space(bar)?/;
/**
* Matches ESC key.
*
* Value from: http://w3c.github.io/uievents-key/#key-Escape
*/
var ESC_KEY = /^escape$/;
/**
* Transforms the key.
* @param {string} key The KeyBoardEvent.key
@ -102,6 +109,8 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
var lKey = key.toLowerCase();
if (lKey === ' ' || SPACE_KEY.test(lKey)) {
validKey = 'space';
} else if (ESC_KEY.test(lKey)) {
validKey = 'esc';
} else if (lKey.length == 1) {
if (!noSpecialChars || KEY_CHAR.test(lKey)) {
validKey = lKey;
@ -145,10 +154,10 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
validKey = 'f' + (keyCode - 112);
} else if (keyCode >= 48 && keyCode <= 57) {
// top 0-9 keys
validKey = String(48 - keyCode);
validKey = String(keyCode - 48);
} else if (keyCode >= 96 && keyCode <= 105) {
// num pad 0-9
validKey = String(96 - keyCode);
validKey = String(keyCode - 96);
} else {
validKey = KEY_CODE[keyCode];
}
@ -313,6 +322,13 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
this._resetKeyEventListeners();
},
/**
* Returns true if a keyboard event matches `eventString`.
*
* @param {KeyboardEvent} event
* @param {string} eventString
* @return {boolean}
*/
keyboardEventMatchesKeys: function(event, eventString) {
var keyCombos = parseEventString(eventString);
for (var i = 0; i < keyCombos.length; ++i) {