Search code examples
javascriptprototypejs

Robust keyboard shortcut handling using JavaScript


What's the most robust way of creating a global keyboard shortcut handler for a Web application using JavaScript i.e. which event(s) should I handle and what should the event handler(s) be attached to?

I want something like the system in Gmail which can handle both single keypress shortcuts and also shortcuts with modifier keys e.g. Ctrl + B etc. The code has to work in IE 6 as well as modern browsers.

I have the Prototype framework available to use but not jQuery, so please, no jQuery-specific answers!


Solution

  • The HotKey library available in the LivePipe controls package works with Prototype and is IE compatible.

    http://livepipe.net/extra/hotkey