Repository navigation
Conversation
v2 had no equivalent of v1's hs.eventtap.event.newSystemKeyEvent(), so media keys couldn't be posted, and only real media key events go through macOS's Now Playing routing. Add makeSystemKeyEvent() and systemKeyStroke() using v1's key names, a systemKeys table, eventTypes.systemDefined, and an event.systemKey property so watchers can recognise these keys too. Fixes #268 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
|
The existing tests only decoded events made by makeSystemKeyEvent(), so repeats, unknown key codes and other systemDefined subtypes went untested, and a mistake shared by the builder and decoder would pass. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Owner
Author
This branch has not been deployed
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.
Fixes #268.
v2 had no equivalent of v1's
hs.eventtap.event.newSystemKeyEvent(), so there was no way to post media keys. Only real media key events go through macOS's Now Playing routing, sohs.audiodeviceor AppleScript workarounds don't cover play/next/previous (e.g. audio in a browser tab).What's new
hs.eventtap.makeSystemKeyEvent(key, isDown)returns an ordinaryHSEventTapEvent, so.post()/.duplicate()work unchangedhs.eventtap.systemKeyStroke(key)presses and releases a key (5 ms between, likekeyStroke)hs.eventtap.systemKeyslists the 22 v1 key names (PLAY,NEXT,SOUND_UP,BRIGHTNESS_UP, …) and theirNX_KEYTYPE_*codes. Names are matched case-insensitively.hs.eventtap.eventTypes.systemDefinedandevent.systemKey({key, keyCode, isDown, isRepeat}, or undefined for other events) let watchers recognise these keysv1's
down/repeatfields becameisDown/isRepeatto match v2 style; the migration guide covers this. The docs warn aboutPOWER/EJECT, and that synthetic brightness keys don't work on some Macs or external displays.Testing
HSEventTapTestspass in a VM. The new tests check every key name, pressed and released, by building an event and decoding it again; they never post one.systemKeyStroke("SOUND_UP")calls raised the output volume from 50 to 63, and asystemDefinedwatcher decoded all four down/up events.npm run docs:generateanddocs:testpass.🤖 Generated with Claude Code