UNPKG

@difizen/mana-core

Version:

697 lines (692 loc) 26.2 kB
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); } var _dec, _class; function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; } function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } } function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; } function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); } function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } /* eslint-disable @typescript-eslint/no-use-before-define */ /* eslint-disable no-param-reassign */ /* eslint-disable no-restricted-syntax */ /* eslint-disable class-methods-use-this */ /* eslint-disable no-plusplus */ import { Emitter, isWindows } from '@difizen/mana-common'; import { inject, optional, singleton } from '@difizen/mana-syringe'; import { KeyboardLayoutProvider, KeyboardLayoutChangeNotifier, KeyValidator } from "./keyboard-protocol"; import { KeyCode, Key } from "./keys"; export var KeyboardLayoutService = (_dec = singleton(), _dec(_class = /*#__PURE__*/function () { function KeyboardLayoutService(layoutProvider, layoutChangeNotifier, keyValidator) { _classCallCheck(this, KeyboardLayoutService); this.keyboardLayoutChanged = new Emitter(); this.layoutProvider = layoutProvider; this.layoutChangeNotifier = layoutChangeNotifier; this.keyValidator = keyValidator; } KeyboardLayoutService = optional()(KeyboardLayoutService, undefined, 2) || KeyboardLayoutService; KeyboardLayoutService = inject(KeyValidator)(KeyboardLayoutService, undefined, 2) || KeyboardLayoutService; KeyboardLayoutService = inject(KeyboardLayoutChangeNotifier)(KeyboardLayoutService, undefined, 1) || KeyboardLayoutService; KeyboardLayoutService = inject(KeyboardLayoutProvider)(KeyboardLayoutService, undefined, 0) || KeyboardLayoutService; _createClass(KeyboardLayoutService, [{ key: "updateLayout", value: function updateLayout(newLayout) { var transformed = this.transformNativeLayout(newLayout); this.currentLayout = transformed; this.keyboardLayoutChanged.fire(transformed); return transformed; } }, { key: "onKeyboardLayoutChanged", get: function get() { return this.keyboardLayoutChanged.event; } }, { key: "initialize", value: function () { var _initialize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() { var _this = this; var initialLayout; return _regeneratorRuntime().wrap(function _callee$(_context) { while (1) switch (_context.prev = _context.next) { case 0: this.layoutChangeNotifier.onDidChangeNativeLayout(function (newLayout) { return _this.updateLayout(newLayout); }); _context.next = 3; return this.layoutProvider.getNativeLayout(); case 3: initialLayout = _context.sent; this.updateLayout(initialLayout); case 5: case "end": return _context.stop(); } }, _callee, this); })); function initialize() { return _initialize.apply(this, arguments); } return initialize; }() /** * Resolve a KeyCode of a keybinding using the current keyboard layout. * If no keyboard layout has been detected or the layout does not contain the * key used in the KeyCode, the KeyCode is returned unchanged. */ }, { key: "resolveKeyCode", value: function resolveKeyCode(inCode) { var layout = this.currentLayout; if (layout && inCode.key) { for (var shift = 0; shift <= 1; shift++) { var index = this.getCharacterIndex(inCode.key, !!shift); var mappedCode = layout.key2KeyCode[index]; if (mappedCode) { var transformed = this.transformKeyCode(inCode, mappedCode, !!shift); if (transformed) { return transformed; } } } } return inCode; } /** * Return the character shown on the user's keyboard for the given key. * Use this to determine UI representations of keybindings. */ }, { key: "getKeyboardCharacter", value: function getKeyboardCharacter(key) { var layout = this.currentLayout; if (layout) { var value = layout.code2Character[key.code]; if (value && value.replace(/[\n\r\t]/g, '')) { return value; } } return key.easyString; } /** * Called when a KeyboardEvent is processed by the KeybindingRegistry. * The KeyValidator may trigger a keyboard layout change. */ }, { key: "validateKeyCode", value: function validateKeyCode(keyCode) { if (this.keyValidator && keyCode.key && keyCode.character) { this.keyValidator.validateKey({ code: keyCode.key.code, character: keyCode.character, shiftKey: keyCode.shift, ctrlKey: keyCode.ctrl, altKey: keyCode.alt }); } } }, { key: "transformKeyCode", value: function transformKeyCode(inCode, mappedCode, keyNeedsShift) { if (!inCode.shift && keyNeedsShift) { return undefined; } if (mappedCode.alt && (inCode.alt || inCode.ctrl || inCode.shift && !keyNeedsShift)) { return undefined; } return new KeyCode({ key: mappedCode.key, meta: inCode.meta, ctrl: inCode.ctrl || mappedCode.alt, shift: inCode.shift && !keyNeedsShift || mappedCode.shift, alt: inCode.alt || mappedCode.alt }); } }, { key: "transformNativeLayout", value: function transformNativeLayout(nativeLayout) { var key2KeyCode = new Array(2 * (Key.MAX_KEY_CODE + 1)); var code2Character = {}; var mapping = nativeLayout.mapping; for (var code in mapping) { if (Object.prototype.hasOwnProperty.call(mapping, code)) { var keyMapping = mapping[code]; var mappedKey = Key.getKey(code); if (mappedKey && this.shouldIncludeKey(code)) { if (isWindows) { this.addWindowsKeyMapping(key2KeyCode, mappedKey, keyMapping.vkey, keyMapping.value); } else { if (keyMapping.value) { this.addKeyMapping(key2KeyCode, mappedKey, keyMapping.value, false, false); } if (keyMapping.withShift) { this.addKeyMapping(key2KeyCode, mappedKey, keyMapping.withShift, true, false); } if (keyMapping.withAltGr) { this.addKeyMapping(key2KeyCode, mappedKey, keyMapping.withAltGr, false, true); } if (keyMapping.withShiftAltGr) { this.addKeyMapping(key2KeyCode, mappedKey, keyMapping.withShiftAltGr, true, true); } } } if (keyMapping.value) { code2Character[code] = keyMapping.value; } } } return { key2KeyCode: key2KeyCode, code2Character: code2Character }; } }, { key: "shouldIncludeKey", value: function shouldIncludeKey(code) { // Exclude all numpad keys because they produce values that are already found elsewhere on the keyboard. // This can cause problems, e.g. if `Numpad3` maps to `PageDown` then commands bound to `PageDown` would // be resolved to `Digit3` (`Numpad3` is associated with `Key.DIGIT3`), effectively blocking the user // from typing `3` in an editor. return !code.startsWith('Numpad'); } }, { key: "addKeyMapping", value: function addKeyMapping(key2KeyCode, mappedKey, value, shift, alt) { var key = VALUE_TO_KEY[value]; if (key) { var index = this.getCharacterIndex(key.key, key.shift); if (key2KeyCode[index] === undefined) { key2KeyCode[index] = new KeyCode({ key: mappedKey, shift: shift, alt: alt, character: value }); } } } }, { key: "addWindowsKeyMapping", value: function addWindowsKeyMapping(key2KeyCode, mappedKey, vkey, value) { var key = VKEY_TO_KEY[vkey]; if (key) { var index = this.getCharacterIndex(key); if (key2KeyCode[index] === undefined) { key2KeyCode[index] = new KeyCode({ key: mappedKey, character: value }); } } } }, { key: "getCharacterIndex", value: function getCharacterIndex(key, shift) { if (shift) { return Key.MAX_KEY_CODE + key.keyCode + 1; } return key.keyCode; } }]); return KeyboardLayoutService; }()) || _class); /** * Mapping of character values to the corresponding keys on a standard US keyboard layout. */ var VALUE_TO_KEY = { '`': { key: Key.BACKQUOTE }, '~': { key: Key.BACKQUOTE, shift: true }, '1': { key: Key.DIGIT1 }, '!': { key: Key.DIGIT1, shift: true }, '2': { key: Key.DIGIT2 }, '@': { key: Key.DIGIT2, shift: true }, '3': { key: Key.DIGIT3 }, '#': { key: Key.DIGIT3, shift: true }, '4': { key: Key.DIGIT4 }, $: { key: Key.DIGIT4, shift: true }, '5': { key: Key.DIGIT5 }, '%': { key: Key.DIGIT5, shift: true }, '6': { key: Key.DIGIT6 }, '^': { key: Key.DIGIT6, shift: true }, '7': { key: Key.DIGIT7 }, '&': { key: Key.DIGIT7, shift: true }, '8': { key: Key.DIGIT8 }, '*': { key: Key.DIGIT8, shift: true }, '9': { key: Key.DIGIT9 }, '(': { key: Key.DIGIT9, shift: true }, '0': { key: Key.DIGIT0 }, ')': { key: Key.DIGIT0, shift: true }, '-': { key: Key.MINUS }, _: { key: Key.MINUS, shift: true }, '=': { key: Key.EQUAL }, '+': { key: Key.EQUAL, shift: true }, a: { key: Key.KEY_A }, A: { key: Key.KEY_A, shift: true }, b: { key: Key.KEY_B }, B: { key: Key.KEY_B, shift: true }, c: { key: Key.KEY_C }, C: { key: Key.KEY_C, shift: true }, d: { key: Key.KEY_D }, D: { key: Key.KEY_D, shift: true }, e: { key: Key.KEY_E }, E: { key: Key.KEY_E, shift: true }, f: { key: Key.KEY_F }, F: { key: Key.KEY_F, shift: true }, g: { key: Key.KEY_G }, G: { key: Key.KEY_G, shift: true }, h: { key: Key.KEY_H }, H: { key: Key.KEY_H, shift: true }, i: { key: Key.KEY_I }, I: { key: Key.KEY_I, shift: true }, j: { key: Key.KEY_J }, J: { key: Key.KEY_J, shift: true }, k: { key: Key.KEY_K }, K: { key: Key.KEY_K, shift: true }, l: { key: Key.KEY_L }, L: { key: Key.KEY_L, shift: true }, m: { key: Key.KEY_M }, M: { key: Key.KEY_M, shift: true }, n: { key: Key.KEY_N }, N: { key: Key.KEY_N, shift: true }, o: { key: Key.KEY_O }, O: { key: Key.KEY_O, shift: true }, p: { key: Key.KEY_P }, P: { key: Key.KEY_P, shift: true }, q: { key: Key.KEY_Q }, Q: { key: Key.KEY_Q, shift: true }, r: { key: Key.KEY_R }, R: { key: Key.KEY_R, shift: true }, s: { key: Key.KEY_S }, S: { key: Key.KEY_S, shift: true }, t: { key: Key.KEY_T }, T: { key: Key.KEY_T, shift: true }, u: { key: Key.KEY_U }, U: { key: Key.KEY_U, shift: true }, v: { key: Key.KEY_V }, V: { key: Key.KEY_V, shift: true }, w: { key: Key.KEY_W }, W: { key: Key.KEY_W, shift: true }, x: { key: Key.KEY_X }, X: { key: Key.KEY_X, shift: true }, y: { key: Key.KEY_Y }, Y: { key: Key.KEY_Y, shift: true }, z: { key: Key.KEY_Z }, Z: { key: Key.KEY_Z, shift: true }, '[': { key: Key.BRACKET_LEFT }, '{': { key: Key.BRACKET_LEFT, shift: true }, ']': { key: Key.BRACKET_RIGHT }, '}': { key: Key.BRACKET_RIGHT, shift: true }, ';': { key: Key.SEMICOLON }, ':': { key: Key.SEMICOLON, shift: true }, "'": { key: Key.QUOTE }, '"': { key: Key.QUOTE, shift: true }, ',': { key: Key.COMMA }, '<': { key: Key.COMMA, shift: true }, '.': { key: Key.PERIOD }, '>': { key: Key.PERIOD, shift: true }, '/': { key: Key.SLASH }, '?': { key: Key.SLASH, shift: true }, '\\': { key: Key.BACKSLASH }, '|': { key: Key.BACKSLASH, shift: true }, '\t': { key: Key.TAB }, '\r': { key: Key.ENTER }, '\n': { key: Key.ENTER }, ' ': { key: Key.SPACE } }; /** * Mapping of Windows Virtual Keys to the corresponding keys on a standard US keyboard layout. */ var VKEY_TO_KEY = { VK_SHIFT: Key.SHIFT_LEFT, VK_LSHIFT: Key.SHIFT_LEFT, VK_RSHIFT: Key.SHIFT_RIGHT, VK_CONTROL: Key.CONTROL_LEFT, VK_LCONTROL: Key.CONTROL_LEFT, VK_RCONTROL: Key.CONTROL_RIGHT, VK_MENU: Key.ALT_LEFT, VK_COMMAND: Key.OS_LEFT, VK_LWIN: Key.OS_LEFT, VK_RWIN: Key.OS_RIGHT, VK_0: Key.DIGIT0, VK_1: Key.DIGIT1, VK_2: Key.DIGIT2, VK_3: Key.DIGIT3, VK_4: Key.DIGIT4, VK_5: Key.DIGIT5, VK_6: Key.DIGIT6, VK_7: Key.DIGIT7, VK_8: Key.DIGIT8, VK_9: Key.DIGIT9, VK_A: Key.KEY_A, VK_B: Key.KEY_B, VK_C: Key.KEY_C, VK_D: Key.KEY_D, VK_E: Key.KEY_E, VK_F: Key.KEY_F, VK_G: Key.KEY_G, VK_H: Key.KEY_H, VK_I: Key.KEY_I, VK_J: Key.KEY_J, VK_K: Key.KEY_K, VK_L: Key.KEY_L, VK_M: Key.KEY_M, VK_N: Key.KEY_N, VK_O: Key.KEY_O, VK_P: Key.KEY_P, VK_Q: Key.KEY_Q, VK_R: Key.KEY_R, VK_S: Key.KEY_S, VK_T: Key.KEY_T, VK_U: Key.KEY_U, VK_V: Key.KEY_V, VK_W: Key.KEY_W, VK_X: Key.KEY_X, VK_Y: Key.KEY_Y, VK_Z: Key.KEY_Z, VK_OEM_1: Key.SEMICOLON, VK_OEM_2: Key.SLASH, VK_OEM_3: Key.BACKQUOTE, VK_OEM_4: Key.BRACKET_LEFT, VK_OEM_5: Key.BACKSLASH, VK_OEM_6: Key.BRACKET_RIGHT, VK_OEM_7: Key.QUOTE, VK_OEM_PLUS: Key.EQUAL, VK_OEM_COMMA: Key.COMMA, VK_OEM_MINUS: Key.MINUS, VK_OEM_PERIOD: Key.PERIOD, VK_F1: Key.F1, VK_F2: Key.F2, VK_F3: Key.F3, VK_F4: Key.F4, VK_F5: Key.F5, VK_F6: Key.F6, VK_F7: Key.F7, VK_F8: Key.F8, VK_F9: Key.F9, VK_F10: Key.F10, VK_F11: Key.F11, VK_F12: Key.F12, VK_F13: Key.F13, VK_F14: Key.F14, VK_F15: Key.F15, VK_F16: Key.F16, VK_F17: Key.F17, VK_F18: Key.F18, VK_F19: Key.F19, VK_BACK: Key.BACKSPACE, VK_TAB: Key.TAB, VK_RETURN: Key.ENTER, VK_CAPITAL: Key.CAPS_LOCK, VK_ESCAPE: Key.ESCAPE, VK_SPACE: Key.SPACE, VK_PRIOR: Key.PAGE_UP, VK_NEXT: Key.PAGE_DOWN, VK_END: Key.END, VK_HOME: Key.HOME, VK_INSERT: Key.INSERT, VK_DELETE: Key.DELETE, VK_LEFT: Key.ARROW_LEFT, VK_UP: Key.ARROW_UP, VK_RIGHT: Key.ARROW_RIGHT, VK_DOWN: Key.ARROW_DOWN, VK_NUMLOCK: Key.NUM_LOCK, VK_NUMPAD0: Key.DIGIT0, VK_NUMPAD1: Key.DIGIT1, VK_NUMPAD2: Key.DIGIT2, VK_NUMPAD3: Key.DIGIT3, VK_NUMPAD4: Key.DIGIT4, VK_NUMPAD5: Key.DIGIT5, VK_NUMPAD6: Key.DIGIT6, VK_NUMPAD7: Key.DIGIT7, VK_NUMPAD8: Key.DIGIT8, VK_NUMPAD9: Key.DIGIT9, VK_MULTIPLY: Key.MULTIPLY, VK_ADD: Key.ADD, VK_SUBTRACT: Key.SUBTRACT, VK_DECIMAL: Key.DECIMAL, VK_DIVIDE: Key.DIVIDE };