From 7846071883d3b6f09f50c1e7dbcafac8bd254a01 Mon Sep 17 00:00:00 2001 From: fauxpark Date: Wed, 3 Apr 2019 11:48:25 +1100 Subject: [PATCH] Capture KC_APP properly (#303) * Capture KC_APP properly * Use a lookup table on ev.key --- src/jquery.js | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/src/jquery.js b/src/jquery.js index aab081b20317..9025662aaf71 100644 --- a/src/jquery.js +++ b/src/jquery.js @@ -45,6 +45,10 @@ function generateKeypressCombos(_keycodes) { return combos; } +const keyLUT = { + ContextMenu: 'KC_APP' +}; + const mods = { KC_LSFT: 'KC_RSFT', KC_LCTL: 'KC_RCTL', @@ -59,16 +63,23 @@ function generateKeypressHandler(keycode) { keys: keycode.keys, on_keydown: ev => { let _meta = meta; - // detect left and right mods - switch (meta.code) { - case 'KC_LSFT': - case 'KC_LGUI': - case 'KC_LALT': - case 'KC_LCTL': - if (ev.location === ev.DOM_KEY_LOCATION_RIGHT) { - _meta = store.getters['keycodes/lookupKeycode'](mods[meta.code]); - } - break; + + // handle special cases eg. ContextMenu + const special = keyLUT[ev.key]; + if (!isUndefined(special)) { + _meta = store.getters['keycodes/lookupKeycode'](special); + } else { + // detect left and right mods + switch (meta.code) { + case 'KC_LSFT': + case 'KC_LGUI': + case 'KC_LALT': + case 'KC_LCTL': + if (ev.location === ev.DOM_KEY_LOCATION_RIGHT) { + _meta = store.getters['keycodes/lookupKeycode'](mods[meta.code]); + } + break; + } } store.commit('keymap/setKeycode', { _code: _meta.code });