Files
kmk_firmware/kmk/handlers/modtap.py
Josh Klar 2c4e866024 Initial attempt to merge internal_state with kmk_keyboard. Seems to work on Plank so far
fix formatting

Example of new "Extension"/plugin system, using LED

Cleanup of RGB code

staticmethod to proper, normal methods

Needs cleanup, but: migrate Leader to Extension API

remove useless self reurns

fix an AttributeError with Leader key removal

Checkpoint from the weekend: split as an Extension (not working or done yet)

wip
2020-11-13 23:27:48 -08:00

24 lines
695 B
Python

from kmk.kmktime import ticks_diff, ticks_ms
def mt_pressed(key, state, *args, **kwargs):
# Sets the timer start and acts like a modifier otherwise
state._keys_pressed.add(key.meta.mods)
state._start_time['mod_tap'] = ticks_ms()
return state
def mt_released(key, state, *args, **kwargs):
# On keyup, check timer, and press key if needed.
state._keys_pressed.discard(key.meta.mods)
timer_name = 'mod_tap'
if state._start_time[timer_name] and (
ticks_diff(ticks_ms(), state._start_time[timer_name]) < state.tap_time
):
state._hid_pending = True
state._tap_key(key.meta.kc)
state._start_time[timer_name] = None
return state