-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support double taps #126
Comments
What about
We don't currently have any concept of multiple keypresses constituting a single "event", such as a double or triple tap, etc. That's a nifty idea though. You could possibly build something like this though by hand with a keymap (and custom function with internal state) - but you'd have to use caps lock as a KEY, not a mod - since keys are the only things you can track discrete presses of in a keymap. It's possible I'm thinking of #92 and things I could imagine but haven't implementer... since to do this now you'd need to capture ALL taps of caps lock and then (if a double tap was detected based on timing, etc) you'd have to switch to a nested keymap that applied CTRL to whatever key you might hit next. |
I thought this would be fun/educational thing to try and proof-of-concept with a custom function in my config. I was wrong. Well, partially. It's not too difficult to use global variables to save the state of when the key was tapped and emit a key (or combo) only when a specified key is "double-tapped" within a certain time period. But the trouble comes when you want to retain a single-tap function for the same key, while also watching for double-taps. You can do an expiring This feels like something that will need an asynchronous type of function that can run in the background after the first tap, watching for the second (or third, fourth, fifth) tap, and then emit the single-tap result only if the defined time interval passes without another tap of the same key. I'm envisioning a syntax somewhat similar to
So for each parameter in order, that would be the key/combo that gets emitted for N taps. There is an optional accessibility feature in Windows to activate "sticky keys" by pressing Shift five times. So there is precedence for a quintuple-tap function, where you really want to avoid triggering it accidentally. As far as the time interval, it would need to be configurable, but the minimum that won't give you a hand cramp is about 0.2s, while a "relaxed" interval is more like 0.3s per tap. In the case of defining only a single-tap function and a quintuple-tap function for the same key (example below), the single-tap function would still need to be delayed for at least the double-tap interval, and probably should be discarded entirely if the user double/triple/quadruple-taps, even if they don't go all the way to the quintuple-tap.
I'm certainly interested to see this kind of functionality added, but at the moment it's beyond my abilities to implement (beyond the simple case of only supporting the double-tap-within-interval, with no single-tap function possible). |
Here is a working "dumb" function that will detect a double-tap and return an output key (or combo, or macro) only if the key is double-tapped within a reasonable time window. The function is of limited usefulness if you want to retain a single-tap function for the key (as discussed above). The key you use will not have any single-tap function (when the chosen keymap is active). I have managed to make it resilient against taps that are too slow, or too fast (as in a held key that starts repeating). But how effective that is will depend on your keyboard's repeat delay and repeat rate setting. If the delay setting is too short, there will be one possibly unwanted "double-tap" output as the key starts rapidly repeating. But under normal circumstances it should work as expected to give a key a function only when double-tapped.
If you want a CapsLock double-tap to be Ctrl+C, it would be like this:
Place the variables and function before the start of the first |
Is your request related to a specific problem you're having?
I'm trying to move my vim usage to be more centered on the keyboard and stop jumping up to ESC to leave insert mode.
The solution you'd prefer or feature you'd like to see added...
I would like to map caps lock to ctrl and then map a double tap of caps lock to the escape key. It wasn't clear from the docs whether keyszer supported double taps.
Any alternative solutions you considered...
I am trying to move to ctrl-c in the meantime. But it's been hard since I keep missing the long press of control and typing 'c' inadvertently.
The text was updated successfully, but these errors were encountered: