Skip to content

Commit

Permalink
Capture KC_APP properly (qmk#303)
Browse files Browse the repository at this point in the history
* Capture KC_APP properly
* Use a lookup table on ev.key
  • Loading branch information
fauxpark authored and yanfali committed Apr 3, 2019
1 parent 716b1cb commit 7846071
Showing 1 changed file with 21 additions and 10 deletions.
31 changes: 21 additions & 10 deletions src/jquery.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ function generateKeypressCombos(_keycodes) {
return combos;
}

const keyLUT = {
ContextMenu: 'KC_APP'
};

const mods = {
KC_LSFT: 'KC_RSFT',
KC_LCTL: 'KC_RCTL',
Expand All @@ -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 });
Expand Down

0 comments on commit 7846071

Please sign in to comment.