Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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!

like image 690
John Topley Avatar asked Mar 04 '09 16:03

John Topley


1 Answers

Just thought I'd throw another into the mix. I recently released a library called Mousetrap. Check it out at http://craig.is/killing/mice

like image 127
Craig Avatar answered Sep 28 '22 06:09

Craig