Chromium Code Reviews| Index: ui/keyboard/resources/elements/kb-key-codes.html |
| diff --git a/ui/keyboard/resources/elements/kb-key-codes.html b/ui/keyboard/resources/elements/kb-key-codes.html |
| index cf1a7c23fa3a0369828f1376f7427fc314b42dc7..c27d2c843e7f485c9a42407ee10514c5ebc1f36b 100644 |
| --- a/ui/keyboard/resources/elements/kb-key-codes.html |
| +++ b/ui/keyboard/resources/elements/kb-key-codes.html |
| @@ -7,6 +7,9 @@ |
| <polymer-element name="kb-key-codes"> |
| <script> |
| (function() { |
| + // Each virtual key event is assigned a unique ID. |
| + var nextRequestID = 0; |
| + |
| // Keycodes have been deprecated in the KeyEvent specification, but are |
| // nonetheless required to support legacy web content. The Keycodes in the |
| // following table are based on subset of US-EN 101-key keyboard. These |
| @@ -139,31 +142,36 @@ |
| /** |
| * Creates a virtual key event for use with the keyboard extension API. |
| - * @param {kb-key} key Instance of the kb-key element being pressed or |
| - * released. |
| + * See http://www.w3.org/TR/DOM-Level-3-Events/#events-KeyboardEvent. |
| + * @param {Object} detail Attribute of the key being pressed or released. |
| * @param {string} type The type of key event, which may be keydown |
| - * or keyreleased. |
| - * @return {keyCode: numeric, |
| - * modifiers: Array.<string>, |
| - * type: string, |
| - * value: string} |
| + * or keyup. |
| + * @return {?KeyboardEvent} A KeyboardEvent object, or undefined on |
| + * failure. |
| */ |
|
bshe
2013/09/03 23:18:11
function names should start with a lower case lett
kevers
2013/09/04 13:51:20
Yes, it should have been lowercase. Fixed.
|
| - CreateVirtualKeyEvent: function(key, type) { |
| - var keyCode = key.keyCode; |
| - var shiftModifier = key.shiftModifier; |
| + CreateVirtualKeyEvent: function(detail, type) { |
| + var char = detail.char; |
| + if (!char || char.length != 1) { |
| + console.error('Invalid key. Expected single character.'); |
| + return; |
| + } |
| + var keyCode = detail.keyCode; |
| + var shiftModifier = detail.shiftModifier; |
| if (keyCode == undefined) { |
| - var state = this.GetKeyCodeAndModifiers(key.charValue); |
| + var state = this.GetKeyCodeAndModifiers(char); |
| + if (state) { |
| keyCode = state.keyCode; |
|
bshe
2013/09/03 23:18:11
nit: indent is off
kevers
2013/09/04 13:51:20
Fixed.
|
| shiftModifier = state.shiftModifier; |
| + } else { |
| + keyCode = 0; |
| + shiftModifier = false; |
| + } |
| } |
| - var modifiers = []; |
| - if (shiftModifier) |
| - modifiers.push('shiftKey'); |
| return { |
| - keyCode: keyCode, |
| - modifiers: modifiers, |
| type: type, |
| - value: key.charValue, |
| + charValue: char.charCodeAt(0), |
| + keyCode: keyCode, |
| + shiftKey: shiftModifier |
| }; |
| }, |
| }); |