Skip to content

Commit

Permalink
Fix dropping keypress if resolved to KC.TRNS
Browse files Browse the repository at this point in the history
  • Loading branch information
xs5871 committed Nov 14, 2023
1 parent 12bca2c commit 689ef82
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
9 changes: 4 additions & 5 deletions kmk/kmk_keyboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,21 +112,20 @@ def _find_key_in_map(self, int_coord: int) -> Key:
except ValueError:
if debug.enabled:
debug('no such int_coord: ', int_coord)

return None

key = None
for layer in self.active_layers:
try:
key = self.keymap[layer][idx]
except IndexError:
key = None
if debug.enabled:
debug('keymap IndexError: idx=', idx, ' layer=', layer)

if not key or key == KC.TRNS:
continue
if key and key != KC.TRNS:
break

return key
return key

def _on_matrix_changed(self, kevent: KeyEvent) -> None:
int_coord = kevent.key_number
Expand Down
8 changes: 8 additions & 0 deletions tests/test_kmk_keys.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ def test_basic_kmk_keyboard(self):
# Note: this is correct, if unusual, syntax. It's a useful test because it failed silently on previous builds.
KC.RALT(KC.LSFT)(KC.N3),
KC.RALT,
KC.TRNS,
]
],
)
Expand Down Expand Up @@ -89,6 +90,13 @@ def test_basic_kmk_keyboard(self):
],
)

keyboard.test(
'Transparent',
[(6, True)],
[{}],
)
self.assertEqual(keyboard.keyboard._coordkeys_pressed, {6: KC.TRNS})

assert isinstance(KC.RGUI(no_press=True), ModifierKey)
assert isinstance(KC.RALT(KC.RGUI), ModifierKey)
assert isinstance(KC.Q(no_press=True), Key)
Expand Down

0 comments on commit 689ef82

Please sign in to comment.