Skip to content

feat: add Insert key support + fix grab crash on hotplug#12

Merged
cjpais merged 3 commits intohandy-computer:mainfrom
zitongcharliedeng:feat/insert-key
Mar 13, 2026
Merged

feat: add Insert key support + fix grab crash on hotplug#12
cjpais merged 3 commits intohandy-computer:mainfrom
zitongcharliedeng:feat/insert-key

Conversation

@zitongcharliedeng
Copy link
Copy Markdown
Contributor

@zitongcharliedeng zitongcharliedeng commented Mar 13, 2026

Adds Insert key support (Key enum, FromStr parser, Display, Linux/Windows keycode mappings) and fixes rdev::grab() dying permanently on keyboard hotplug by adding a retry loop.

Insert was the only navigation key missing from the Key enum. The grab retry fix prevents hotkeys from breaking when USB keyboards are plugged/unplugged — previously the listener thread would exit on any grab error with no recovery.

Note: the listener.rs diff is large (174 lines) but is mostly re-indentation from wrapping the existing callback + grab call in a retry loop {}. The actual new logic is ~6 lines (match on grab error, sleep 2s, retry).

Add Insert variant to Key enum with parser aliases ("insert", "ins"),
Display output, and platform keycode mappings for Linux (evdev) and
Windows (VK_INSERT). macOS is skipped as Mac keyboards lack Insert.

Closes handy-computer#11

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@zitongcharliedeng zitongcharliedeng marked this pull request as draft March 13, 2026 02:27
zitongcharliedeng added a commit to zitongcharliedeng/Handy that referenced this pull request Mar 13, 2026
Point handy-keys at fork with Insert key support (handy-computer/handy-keys#12).
Users can now bind actions to the Insert key.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
zitongcharliedeng added a commit to zitongcharliedeng/Handy that referenced this pull request Mar 13, 2026
Point handy-keys at fork with Insert key support (handy-computer/handy-keys#12).
Users can now bind actions to the Insert key.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
rdev::grab() fails permanently on device hotplug (new keyboard
plugged in, etc.) because it enumerates evdev devices once at
grab time. Previously the listener thread would just exit,
permanently killing all hotkeys until app restart.

Now retries with 2s backoff, re-enumerating devices on each
attempt. Respects the running flag to stop retrying on shutdown.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@zitongcharliedeng zitongcharliedeng changed the title feat: add Insert key support feat: add Insert key support + fix grab crash on hotplug Mar 13, 2026
@zitongcharliedeng zitongcharliedeng marked this pull request as ready for review March 13, 2026 04:07
@cjpais
Copy link
Copy Markdown
Contributor

cjpais commented Mar 13, 2026

Thanks for this. One question, this hot-plug behavior with the issue, what happens exactly? And will this just keep erroring endlessly for two seconds, or will the next grab be expected to work? Looping every 2 seconds maybe isn't great if it's always going to throw every 2 seconds. But if it throws once, recovers and not throw again I think that is reasonable. I just don't know this path well enough.

@zitongcharliedeng
Copy link
Copy Markdown
Contributor Author

zitongcharliedeng commented Mar 13, 2026

The next grab should be expected to work. Currently if I plug in just an extra keyboard or something, the rdev listener would just permanently unbind for both forever and I'd have to manually reset Handy to get it working again.

We could make it just try again a limited number of times if you are worried about the loop but I think it's fine to cover more cases.

@cjpais
Copy link
Copy Markdown
Contributor

cjpais commented Mar 13, 2026

Nah I think it's good, going to merge, thanks

@cjpais cjpais merged commit 31ee5bc into handy-computer:main Mar 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants