🐞 Consume unmatched keys while Loop is open and the trigger is held#1116
Open
bit-saver wants to merge 1 commit into
Open
🐞 Consume unmatched keys while Loop is open and the trigger is held#1116bit-saver wants to merge 1 commit into
bit-saver wants to merge 1 commit into
Conversation
When Loop is open and the trigger key is still held (mid-chord), a keyDown that doesn't match any bound action fell through to `.forward`, leaking the key to the focused app (e.g. typing "2" repeatedly during a `trigger+2+arrow` chord that isn't bound). Consume unmatched keyDowns while Loop is open and the trigger is held; releases and post-trigger keys still forward.
Owner
|
I think this requires further discussion. Currently, it’s intended behavior that unmatched key combos pass through Loop. This is important for setups where a user might set Hyper as the trigger key, assign some shortcuts in Loop, and still use other Hyper-based shortcuts in other apps. That said, I can see how this passthrough could become annoying for combos with more than one non-modifier key event. Maybe a small delay before passing the event through, to check whether another key is pressed, could make sense? Though that should definitely be handled outside the |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
While Loop is open and the trigger key is still held (mid-chord), a
keyDownthat doesn't match any bound action leaks to the focused app — e.g. holding the trigger and pressing an unbound "2" types "2222…" into the frontmost app.Root cause
KeybindTrigger.performKeybindends withreturn .forwardfor any event that didn't match an action. That's correct when Loop is closed, but while Loop is open and the trigger is held, unmatched keyDowns should be consumed (the user is mid-chord). No branch handles that case, so it falls through to.forward.(Users currently work around this by binding the key to a "do nothing" action, which makes it "match" and thus consume.)
Fix
Consume unmatched keyDowns while Loop is open and the trigger is held. Gated on
checkIfLoopOpen(),containsTrigger, andtype == .keyDown, so: keys still forward when Loop is closed; key releases (keyUp) still forward; keys typed after releasing the trigger still forward; and the emoji/globe special-event passthrough (handled earlier) is unaffected.Testing
Built (Release) and verified in real use: an unbound key pressed mid-chord is no longer typed into the focused app; normal typing (Loop closed) and other chords are unaffected.
Note / edge case
Returning
.consumeshort-circuits the outer system-keybind passthrough, so a global shortcut pressed simultaneously with the held Loop trigger would be swallowed rather than forwarded + force-close Loop. This is rare (requires holding the Loop trigger during a system shortcut). If you'd prefer to preserve it, the consume can be gated behind a system-keybind-cache check — happy to adjust.