Repository navigation
Tap and hold on the same key #286
nikbrunner
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
I'd like to bind one key to two actions: a tap, and a hold past a delay that ends when the key is released.
The case is an image annotation editor. Tapping A moves focus to the tool rail. Holding A opens a tool menu at the pointer, and releasing picks the tool under it. Holding S does the same for the active tool's settings. A tool key could also be spring-loaded: hold E to erase, release to go back to the brush.
The parts exist.
requireResetfires a keydown once per press, akeyupchord fires for the release of a press it recorded (#258), anduseKeyHoldreports whether a key is down. What every app has to write itself is the timer and its edge cases: clearing it on release and on window blur, cancelling the hold when another key goes down during it, and deciding whether the tap fires on keydown or only on a release before the delay.Something like this would cover it:
The tap would fire on keydown as it does today, so taps never wait for the delay. An app that wants the tap only when no hold follows could opt into firing it on release instead.
Would you take this into the library, or should it stay in app code?
All reactions