updates based on review comments

This commit is contained in:
Syed Hussaini 2022-04-25 08:51:26 -05:00 committed by xs5871
parent bce7959f66
commit 1b902b907c
2 changed files with 14 additions and 10 deletions

View File

@ -27,17 +27,15 @@ class ModHoldAndTap(Module):
def process_key(self, keyboard, key, is_pressed, int_coord):
if isinstance(key.meta, ModHoldAndTapValidator):
layer_id = keyboard.active_layers[0]
if layer_id > 0:
if self._active and self._prev_key is not None and is_pressed:
# release previous key
self.release(keyboard, self._prev_key)
self._prev_key = key
if is_pressed:
keyboard.process_key(key.meta.mod, is_pressed)
if self._active and self._prev_key is not None and is_pressed:
# release previous key
self.release(keyboard, self._prev_key)
self._prev_key = key
if is_pressed:
keyboard.process_key(key.meta.mod, is_pressed)
self._active = True
keyboard.process_key(key.meta.kc, is_pressed)
self._active = True
keyboard.process_key(key.meta.kc, is_pressed)
elif self._active:
# release previous key if any other key is pressed

View File

@ -46,6 +46,10 @@ class TestModHoldLayerTap(unittest.TestCase):
(1, False),
],
[
{KC.LSFT, KC.LCTL, KC.TAB},
{KC.LSFT, KC.LCTL},
{KC.LSFT, KC.LCTL, KC.TAB},
{KC.LSFT, KC.LCTL},
{KC.B},
{},
],
@ -97,6 +101,8 @@ class TestModHoldLayerTap(unittest.TestCase):
{KC.LGUI},
{KC.B},
{},
{KC.LSFT, KC.LCTL, KC.TAB},
{KC.LSFT, KC.LCTL},
{KC.B},
{},
],