Merge pull request #28 from KMKfw/topic-grave-escape

Topic grave escape
This commit is contained in:
Josh Klar 2018-09-29 16:29:48 -07:00 committed by GitHub
commit a1bfaac691
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 37 additions and 5 deletions

View File

@ -16,13 +16,44 @@ def process_internal_key_event(state, action, changed_key, logger=None):
return tg(state, action, changed_key, logger=logger)
elif changed_key.code == Keycodes.Layers._KC_TO:
return to(state, action, changed_key, logger=logger)
elif changed_key == Keycodes.KMK.KC_GESC:
return grave_escape(action, state, logger=logger)
else:
return state
def tilde(state, action, changed_key, logger):
# TODO Actually process keycodes
return state
def grave_escape(action, state, logger):
if action['type'] == KEY_DOWN_EVENT:
for key in state.keys_pressed:
if key in {Keycodes.Modifiers.KC_LSHIFT, Keycodes.Modifiers.KC_RSHIFT}:
# if Shift is held, return KC_GRAVE which will become KC_TILDE on OS level
return state.update(
keys_pressed=(
state.keys_pressed | {Keycodes.Common.KC_GRAVE}
),
)
elif key in {Keycodes.Modifiers.KC_LGUI, Keycodes.Modifiers.KC_RGUI}:
# if GUI is held, return KC_GRAVE
return state.update(
keys_pressed=(
state.keys_pressed | {Keycodes.Common.KC_GRAVE}
),
)
# else return KC_ESC
return state.update(
keys_pressed=(
state.keys_pressed | {Keycodes.Common.KC_ESCAPE}
),
)
elif action['type'] == KEY_UP_EVENT:
return state.update(
keys_pressed=frozenset(
key for key in state.keys_pressed
if key not in {Keycodes.Common.KC_ESCAPE, Keycodes.Common.KC_GRAVE}
),
)
def df(state, action, changed_key, logger):

View File

@ -0,0 +1 @@
SUBSYSTEMS=="usb", ATTRS{idVendor}=="0483", ATTRS{idProduct}=="df11", GROUP="uucp", MODE="0660"

View File

@ -14,7 +14,7 @@ diode_orientation = DiodeOrientation.COLUMNS
keymap = [
[
# Default
[KC.ESC, KC.QUOTE, KC.COMMA, KC.DOT, KC.P, KC.Y, KC.F, KC.G, KC.C, KC.R, KC.L, KC.BKSP],
[KC.GESC, KC.QUOTE, KC.COMMA, KC.DOT, KC.P, KC.Y, KC.F, KC.G, KC.C, KC.R, KC.L, KC.BKSP],
[KC.TAB, KC.A, KC.O, KC.E, KC.U, KC.I, KC.D, KC.H, KC.T, KC.N, KC.S, KC.ENT],
[KC.LSFT, KC.SCLN, KC.Q, KC.J, KC.K, KC.X, KC.B, KC.M, KC.W, KC.V, KC.Z, KC.SLSH],
[KC.LCTRL, KC.LGUI, KC.LALT, KC.MO(2), KC.MO(3), KC.SPC, KC.SPC, KC.MO(4), KC.LEFT, KC.DOWN, KC.UP, KC.RIGHT],

View File

@ -12,7 +12,7 @@ diode_orientation = DiodeOrientation.COLUMNS
keymap = [
[
[KC.MO(1), KC.H, KC.RESET],
[KC.MO(1), KC.GESC, KC.RESET],
[KC.MO(2), KC.HASH, KC.ENTER],
[KC.LCTRL, KC.SPACE, KC.LSHIFT],
],