Add a session event tap as a fallback for cmd-cmd chord detection#9
Merged
Add a session event tap as a fallback for cmd-cmd chord detection#9
Conversation
NSEvent global/local monitors can miss flag-change events when other apps consume modifiers, when accessibility permission was just granted, or under certain key-remapping setups. Add a CGEventTap on the session in passive .listenOnly mode (alongside the existing NSEvent monitors) so the chord state machine sees flag changes from a second source. The tap dispatches to main async, never consumes events, and re-uses the same handleFlags state machine. The 'fired' flag dedupes when both sources race the same chord. Falls back silently if the tap can't be created (no Accessibility permission yet). Skips the in-overlay key tap from the original PR — the overlay window becomes key and the existing NSResponder path works there. Co-Authored-By: plyght <plyght@peril.lol> Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Closed
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.
`NSEvent` global/local monitors can miss flag-change events under various conditions (other apps consuming modifiers, accessibility permission just-granted, key-remapping software). Add a `CGEventTap` on `.cgSessionEventTap` in passive `.listenOnly` mode as a second source for chord detection.
Scope reduced from #1: the in-overlay key event tap from the original PR is not included here. The overlay window already becomes key and the existing NSResponder path captures keys correctly. That tap was needed only for the minimal-mode panel which isn't part of this slice.
Credit to @plyght — adapted from #1.
Test plan
🤖 Generated with Claude Code