Minor code cleanup

* Changed from multiple calls of `keyboard.remove_key` to a for loop when releasing modifiers on match
This commit is contained in:
James Fitzgerald 2022-07-09 11:41:35 -04:00 committed by xs5871
parent 688c2f0572
commit 25a86df5c1

View File

@ -178,14 +178,19 @@ class StringSubstitution(Module):
# it should not be possible for any modifiers other than shift to be held upon rule activation # it should not be possible for any modifiers other than shift to be held upon rule activation
# as a modified key won't send a keycode that is matched against the user's dictionary, # as a modified key won't send a keycode that is matched against the user's dictionary,
# but, just in case, we'll release those too # but, just in case, we'll release those too
keyboard.remove_key(KC.LSFT) modifiers_to_release = [
keyboard.remove_key(KC.RSFT) KC.LSFT,
keyboard.remove_key(KC.LCTL) KC.RSFT,
keyboard.remove_key(KC.RCTL) KC.LCTL,
keyboard.remove_key(KC.LALT) KC.LGUI,
keyboard.remove_key(KC.RALT) KC.LALT,
keyboard.remove_key(KC.LGUI) KC.RCTL,
keyboard.remove_key(KC.RGUI) KC.RGUI,
KC.RALT,
]
for modifier in modifiers_to_release:
keyboard.remove_key(modifier)
# send backspace taps equivalent to the length of the phrase to be substituted # send backspace taps equivalent to the length of the phrase to be substituted
to_substitute: Phrase = self._matched_rule.to_substitute # type: ignore to_substitute: Phrase = self._matched_rule.to_substitute # type: ignore
to_substitute.next_character() to_substitute.next_character()