Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix sticky_keys hold release #1055

Merged
merged 7 commits into from
Dec 14, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/en/sticky_keys.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ KC.SK(
### `defer_release`

If `False` (default): release sticky key after the first interrupting key
releases.
is released, or another is pressed. THis PRevents TYpos LIke THese.
xs5871 marked this conversation as resolved.
Show resolved Hide resolved
If `True`: stay sticky until all keys are released. Useful when combined with
non-sticky modifiers, layer keys, etc...

Expand Down
13 changes: 5 additions & 8 deletions kmk/modules/sticky_keys.py
xs5871 marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -124,20 +124,17 @@ def on_release(self, key, keyboard, *args, **kwargs):
key.state = _SK_RELEASED
# Key in HOLD state is handled like a regular release.
elif key.state == _SK_HOLD:
for sk in self.active_keys.copy():
keyboard.cancel_timeout(sk.timeout)
self.deactivate(keyboard, sk)
keyboard.cancel_timeout(key.timeout)
self.deactivate(keyboard, key)

def on_release_after(self, keyboard, key):
# Key is still pressed but nothing else happend: set to HOLD.
if key.state == _SK_PRESSED:
for sk in self.active_keys:
key.state = _SK_HOLD
keyboard.cancel_timeout(sk.timeout)
key.state = _SK_HOLD
keyboard.cancel_timeout(key.timeout)
# Key got released but nothing else happend: deactivate.
elif key.state == _SK_RELEASED:
for sk in self.active_keys.copy():
self.deactivate(keyboard, sk)
self.deactivate(keyboard, key)

def activate(self, keyboard, key):
if debug.enabled:
Expand Down
4 changes: 2 additions & 2 deletions tests/test_sticky_keys.py
Original file line number Diff line number Diff line change
Expand Up @@ -397,8 +397,8 @@ def test_sticky_key_deferred(self):
{KC.N0, KC.N1, KC.N2},
{KC.N0, KC.N1, KC.N2, KC.N3},
{KC.N0, KC.N2, KC.N3},
{KC.N2, KC.N3},
{KC.N3},
{KC.N0, KC.N3},
{KC.N0},
xs5871 marked this conversation as resolved.
Show resolved Hide resolved
{},
],
)
Expand Down
Loading
Loading