<story><title>Keypress: A Javascript library for capturing input</title><url>http://dmauro.github.io/Keypress/</url></story><parent_chain></parent_chain><comment><author>pyalot2</author><text>Note that you should avoid using this (or anything else with JS) to emulate shortcuts.&lt;p&gt;The reason is because what this usually looks like &amp;quot;oh nice I can define shortcuts people can press&amp;quot;. What it actually means is: &amp;quot;Ohcrap, that shortcut only works for US-US 104 keyboard layouts, and about 80% of people can&amp;#x27;t press that shortcut&amp;quot;.&lt;p&gt;For example: suppose you want a shortcut for shift+&amp;#x2F;, which is for the US keyboard under the small right finger. But that shortcut can&amp;#x27;t be defined for SG (swiss-german) because there the &amp;#x2F; is on the numeric bar where 7 is. So if you assume (for whatever reason) that left+right small finger is a convenient shortcut, and left small finger + right index finger top isn&amp;#x27;t, then you&amp;#x27;re totally screwed. Instead, to reach the right small finger low on swiss german, you&amp;#x27;d have to define shift + &amp;quot;-&amp;quot;. Except that if you define that, it&amp;#x27;ll be one of the most uncomfortable keyboard shortcuts imaginable for US users, which find - on the numeric row top --&amp;gt; bottom left small finger + top right small finger = ugh.&lt;p&gt;The truth is that you cannot do reasonable shortcut definition the way that everybody would like to with JS... yet.&lt;p&gt;But wait, can&amp;#x27;t you like, define some reasonable presets and let people choose their own? The answer is no, because you don&amp;#x27;t have a reliable way to translate a keydown&amp;#x2F;keyup to a unicode char, and the unicode char is related to the modifier keys, not the key cap, so though you can do that shortcut definition, you can&amp;#x27;t show to the user what that shortcut definition actually is, because it&amp;#x27;d be either undefined or completely wrong.&lt;p&gt;I&amp;#x27;ve written at length about this here: &lt;a href=&quot;http://codeflow.org/entries/2013/jan/30/keyboard-events-in-javascript-are-broken/&quot; rel=&quot;nofollow&quot;&gt;http:&amp;#x2F;&amp;#x2F;codeflow.org&amp;#x2F;entries&amp;#x2F;2013&amp;#x2F;jan&amp;#x2F;30&amp;#x2F;keyboard-events-in-j...&lt;/a&gt;</text></comment>
<story><title>Keypress: A Javascript library for capturing input</title><url>http://dmauro.github.io/Keypress/</url></story><parent_chain></parent_chain><comment><author>stephen</author><text>Tangentially, can someone on the W3C please fix the sorry state of key bindings across UAs?&lt;p&gt;Cross-browser idiosyncrasies are finally improving...except for webapp key bindings. Alt-F is taken in IE, Ctrl-whatever is taken in other UAs. Or an extension like (the awesome) vimium conflicts with some key bindings, so you have to disable it all together.&lt;p&gt;To the point where Asana uses &lt;i&gt;tab&lt;/i&gt; as their short cut key. Tab! Wtf! &amp;quot;tab-p&amp;quot; for project. Bizarre!&lt;p&gt;But I guess I can&amp;#x27;t blame them, as I wouldn&amp;#x27;t be surprised if it&amp;#x27;s the only shortcut modifier that wasn&amp;#x27;t taken yet across all UAs.&lt;p&gt;I admittedly have no solutions to propose, so am just ranting about an understandably hard problem...but it would be nice if someone came along and fixed this. Please. :-)</text></comment>