| Index: ui/webui/resources/js/util.js
|
| diff --git a/ui/webui/resources/js/util.js b/ui/webui/resources/js/util.js
|
| index 048a674ed1980061b6cb9802866a25fefdd75a55..b3fb8d485279e2eee2571d30877bea460ea32abd 100644
|
| --- a/ui/webui/resources/js/util.js
|
| +++ b/ui/webui/resources/js/util.js
|
| @@ -372,3 +372,69 @@ function elide(original, maxLength) {
|
| function quoteString(str) {
|
| return str.replace(/([\\\.\+\*\?\[\^\]\$\(\)\{\}\=\!\<\>\|\:])/g, '\\$1');
|
| }
|
| +
|
| +<if expr="is_ios">
|
| +// Polyfill 'key' in KeyboardEvent for iOS.
|
| +// This function is not intended to be complete but should
|
| +// be sufficient enough to have iOS work correctly while
|
| +// it does not support key yet.
|
| +if (!('key' in KeyboardEvent.prototype)) {
|
| + Object.defineProperty(KeyboardEvent.prototype, 'key', {
|
| + get: function () {
|
| + // 0-9
|
| + if (this.keyCode >= 0x30 && this.keyCode <= 0x39)
|
| + return String.fromCharCode(this.keyCode);
|
| +
|
| + // A-Z
|
| + if (this.keyCode >= 0x41 && this.keyCode <= 0x5a) {
|
| + var result = String.fromCharCode(this.keyCode).toLowerCase();
|
| + if (this.shiftKey)
|
| + result = result.toUpperCase();
|
| + return result;
|
| + }
|
| +
|
| + // Special characters
|
| + switch(this.keyCode) {
|
| + case 0x08: return 'Backspace';
|
| + case 0x09: return 'Tab';
|
| + case 0x0d: return 'Enter';
|
| + case 0x10: return 'Shift';
|
| + case 0x11: return 'Control';
|
| + case 0x12: return 'Alt';
|
| + case 0x1b: return 'Escape';
|
| + case 0x20: return ' ';
|
| + case 0x21: return 'PageUp';
|
| + case 0x22: return 'PageDown';
|
| + case 0x23: return 'End';
|
| + case 0x24: return 'Home';
|
| + case 0x25: return 'ArrowLeft';
|
| + case 0x26: return 'ArrowUp';
|
| + case 0x27: return 'ArrowRight';
|
| + case 0x28: return 'ArrowDown';
|
| + case 0x2d: return 'Insert';
|
| + case 0x2e: return 'Delete';
|
| + case 0x5b: return 'Meta';
|
| + case 0x70: return 'F1';
|
| + case 0x71: return 'F2';
|
| + case 0x72: return 'F3';
|
| + case 0x73: return 'F4';
|
| + case 0x74: return 'F5';
|
| + case 0x75: return 'F6';
|
| + case 0x76: return 'F7';
|
| + case 0x77: return 'F8';
|
| + case 0x78: return 'F9';
|
| + case 0x79: return 'F10';
|
| + case 0x7a: return 'F11';
|
| + case 0x7b: return 'F12';
|
| + case 0xbb: return '=';
|
| + case 0xbd: return '-';
|
| + case 0xdb: return '[';
|
| + case 0xdd: return ']';
|
| + }
|
| + return 'Unidentified';
|
| + }
|
| + });
|
| +} else {
|
| + window.console.log("KeyboardEvent.Key polyfill not required");
|
| +}
|
| +</if> /* is_ios */
|
|
|