diff --git a/kmk/kmk_keyboard.py b/kmk/kmk_keyboard.py index cee6b2f7f..9012ef9db 100644 --- a/kmk/kmk_keyboard.py +++ b/kmk/kmk_keyboard.py @@ -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 diff --git a/tests/test_kmk_keys.py b/tests/test_kmk_keys.py index 6e0488f8b..ae664e259 100644 --- a/tests/test_kmk_keys.py +++ b/tests/test_kmk_keys.py @@ -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, ] ], ) @@ -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)