mousetrap icon indicating copy to clipboard operation
mousetrap copied to clipboard

New feature request: Support for key *and* key key events

Open moebius-rex opened this issue 6 years ago • 0 comments

Hi Craig. Fantastic product!

I have an Electron app that makes full use of Mousetrap and most of the shortcuts I use are single key, like "left", "home", etc. — so much better than using modifiers if you can get away with it. I recently added a "left left" shortcut and while it works beautifully, it hides the "left" shortcut I had already defined. I expect that you start a timer whenever you detect a key that's part of a multi-key sequence and discard the key event when the timer expires. Would it be possible, perhaps configurably, to execute the action associated with the single key shortcut? I know there's a possibility that this may cause confusion amongst users and even developers, so perhaps you could allow a much shorter timeout for repeated key sequences since your finger is already over the next key in the sequence, for example, the timeout between w and q in "w q" would be the normal half-second (I'm guessing based on my own observations) but only a quarter of a second between the repeated w in "w w", but only if there's a single "w" shortcut defined. That should reduce any chance of confusion.

Right now I'm using "up" instead of "left left" and of course that's fine. I use "left", "right", "up" and "down" to navigate an onscreen page stack, and while not being able to use "left" and "left left" won't be kill me, the association it would create with the user is hard to put out of my mind.

So, there you have it. I'd be interested in your thoughts. Once again, great product! Actually the best I've used from npm. Seriously!

Thanks, Shay

PS I wrote a small utility module that lets you set up Mousetrap bindings using a configuration file and also allows you to merge multiple config files so that you can have for example default and custom key mappings. I use it in my app and it works every time. Any interest in adding it to Mousetrap or should I just add it to npm and reference Mousetrap?

moebius-rex avatar Apr 27 '18 18:04 moebius-rex