diff --git a/kmk/key_validators.py b/kmk/key_validators.py index 5662c61..e819275 100644 --- a/kmk/key_validators.py +++ b/kmk/key_validators.py @@ -22,11 +22,11 @@ def layer_key_validator(layer, kc=None): return LayerKeyMeta(layer=layer, kc=kc) -def mod_tap_validator(kc, mods=None, prefer_hold=True): +def mod_tap_validator(kc, mods=None, prefer_hold=True, tap_time=None): ''' Validates that mod tap keys are correctly used ''' - return ModTapKeyMeta(kc=kc, mods=mods, prefer_hold=prefer_hold) + return ModTapKeyMeta(kc=kc, mods=mods, prefer_hold=prefer_hold, tap_time=tap_time) def tap_dance_key_validator(*codes): diff --git a/kmk/modules/holdtap.py b/kmk/modules/holdtap.py index b5fc34f..a756fcd 100644 --- a/kmk/modules/holdtap.py +++ b/kmk/modules/holdtap.py @@ -61,8 +61,12 @@ class HoldTap(Module): def ht_pressed(self, key, keyboard, *args, **kwargs): '''Do nothing yet, action resolves when key is released, timer expires or other key is pressed.''' + if key.meta.tap_time is None: + tap_time = self.tap_time + else: + tap_time = key.meta.tap_time timeout_key = keyboard.set_timeout( - self.tap_time, + tap_time, lambda: self.on_tap_time_expired(key, keyboard, *args, **kwargs), ) self.key_states[key] = HoldTapKeyState(timeout_key, *args, **kwargs) diff --git a/kmk/types.py b/kmk/types.py index 0fc5ceb..10d5802 100644 --- a/kmk/types.py +++ b/kmk/types.py @@ -12,16 +12,18 @@ class AttrDict(dict): class LayerKeyMeta: - def __init__(self, layer, kc=None): + def __init__(self, layer, kc=None, tap_time=None): self.layer = layer self.kc = kc + self.tap_time = tap_time class ModTapKeyMeta: - def __init__(self, kc=None, mods=None, prefer_hold=True): + def __init__(self, kc=None, mods=None, prefer_hold=True, tap_time=None): self.prefer_hold = prefer_hold self.kc = kc self.mods = mods + self.tap_time = tap_time class KeySequenceMeta: