Keypress: A robust JavaScript library for capturing keyboard input

  • A big problem I experience is the lack of web-safe keyboard shortcuts for complex web-apps. If looking for a safe key-combination, you have to consider the superset of OS and Browser combinations and that leaves almost nothing.

    The gmail approach is for unmodified keys but that only works if you don't have focus in an editable field. The gdocs approach is for menu chords but that sucks for frequent actions and still generates weird dual handling of events by the browser.

    I'd love a web/browser standards committee to preserve the universal utility of the keyboard. It could ring-fence some application specific shortcuts, give a semantic abstraction of some actions e.g. undo, and standardise mechanisms for os specific remappings.

    As it is, as more tech comes along, the less usable keyboards become. I am still dumbfounded that the iPad lacks a tab button or any chord for one despite claiming to be usable for word-processing. This basically means no web-app can ever assume a keyboard has a tab key. Gah.

  • Getting an error on that page in Chrome.

        Refused to execute script from 'https://rawgithub.com/dmauro/Keypress/master/keypress.js' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled.
    
    EDIT: It's because Keypress is using rawgit.com instead of cdn.rawgit.com to host the actual keypress.js script.

    Details here - http://rawgit.com/dmauro/Keypress/master/keypress.js

    Working script source - http://cdn.rawgit.com/dmauro/Keypress/master/keypress.js

  • Previous discussion https://news.ycombinator.com/item?id=6464138

        Keypress: A Javascript library for capturing input (dmauro.github.io)
        192 points by nsmalch 468 days ago | flag | cached | share | comments

  • An alternative is mouestrap: http://craig.is/killing/mice

    I've used it successfully in Marionette and Angular applications.

    It is 29k unminified, vs 35k of keypress.js.

  • I'd like to see scoping added so it's possible to easily switch keyboard bindings based on the feature/context.

    https://github.com/madrobby/keymaster does an OK job with this, and too bad it's not being actively maintained.

  • More aimed at game developers, but for anyone who wants a super lightweight subset of this functionality.

    https://github.com/danprince/keystate

  • Now with Konami code!