Re:Mousetrap: Keyboard shortcuts in Javascript
by ajross on Thursday July 05, 2012 @02:50PM
(#4204359)
It doesn't do modifier key event generation correctly. On a US keyboard, hold down shift and 4 (i.e. type "$"). The second item highlights. Now release shift. The first item highlights, incorrectly, because the library apparently generated a keydown event for "4" when the shift key was released. That's wrong by all standard conventions. Modifier key releases should never synthesize presses.
[ Parent
| on HN ]
Re:Mousetrap: Keyboard shortcuts in Javascript
by craigc on Thursday July 05, 2012 @02:55PM
(#4204383)
What browser are you using? It works correctly for me using Chrome on Mac. Could you make a ticket on Github?
Re:Mousetrap: Keyboard shortcuts in Javascript
by ajross on Thursday July 05, 2012 @03:18PM
(#4204509)
Chrome 20 on linux. Bug submitted: https://github.com/ccampbell/mousetrap/issues/3
Re:Mousetrap: Keyboard shortcuts in Javascript
by antoko on Thursday July 05, 2012 @06:32PM
(#4205331)
same issue on Win7 / FF13
Also affects the "* a" combo if you release shift before releasing 8 then release 8 and press "a" it doesn't recognize the combination (presumably because its reading a key press of 8 in between them)
Re:Mousetrap: Keyboard shortcuts in Javascript
by craigc on Thursday July 05, 2012 @03:23PM
(#4204531)
Thank you.
Re:Mousetrap: Keyboard shortcuts in Javascript
by craigc on Thursday July 05, 2012 @06:34PM
(#4205343)
I wonder if this is related to https://github.com/ccampbell/mousetrap/issues/6
In which case it should be a pretty painless fix.
Re:Mousetrap: Keyboard shortcuts in Javascript
by bederoso on Thursday July 05, 2012 @04:57PM
(#4204926)
I know it doesn't actually say that Opera is supported, but all highlights work, and that little bug he mentioned also occurs in Opera
Re:Mousetrap: Keyboard shortcuts in Javascript
by jabiko on Thursday July 05, 2012 @03:49PM
(#4204651)
I think there is no way to change this behavior: https://developer.mozilla.org/en/DOM/KeyboardEvent#Auto-repe...
Re:Mousetrap: Keyboard shortcuts in Javascript
by ajross on Thursday July 05, 2012 @04:03PM
(#4204712)
It's a mess (the core problem is that the X server automatically generates release/press event pairs to implement key repeat which can't affirmatively be detected as "synthetic"). But it's handlable heuristically.
The way I've seen it done it via a timeout on "release after a long press". If the key has been down for more than ~1 second, then hold off on interpreting a release event to see if there's a matching press already queued in the pipe or not. The timeout can be very short (the X server sends them both synchronously down the socket with no delay).