I'm making a web application that uses the keyboard quite extensively. I notice that the builtin browser event handling is inconsistent across browsers, and jQuery does not normalize very well (eg. Firefox sends a keypress
for backspace, chrome doesn't). I'm wondering if there is a javascript library that normalizes these idiosyncrasies and presents a uniform interface to keyboard event handling.
Asked
Active
Viewed 473 times
7

luqui
- 59,485
- 12
- 145
- 204
-
I don't have an answer to your larger question, but I do know it's recommended to use 'keyup' instead of 'keypress' because of lack of implementation across browsers. – kinakuta Jun 19 '11 at 19:02
-
[Would this be an answer?](http://stackoverflow.com/questions/2353417/which-is-the-best-javascript-keyboard-event-library-hotkeys-shortcuts) – Uwe Keim Jun 19 '11 at 19:06
-
2You may be doing something that will be wonderful, but just as a note: it's pretty risky to make a web application that behaves in ways that are significantly different from other web applications. For something like a game, it may be a *great* idea because it may add interest and challenge. For something like a banking application, it may cause a lot of confusion and frustration. – Pointy Jun 19 '11 at 19:08
-
1Try http://www.stepanreznikov.com/js-shortcuts/ – spacevillain Jun 20 '11 at 07:36
-
2@kinakuta: You can't use `keyup` instead of `keypress` in general: they serve different purposes. `keyup` fires when a key is released whereas `keypress` fires immediately after a key is pushed down (and may be fired when auto-repeating characters are generated as the key is held down). `keypress` is the only event that can tell you anything reliable about the character typed; `keyup` and `keydown` only tell you the code of the physical key that was pressed/released. Actually all major browsers support `keypress`, but there is some variation in implementation: http://unixpapa.com/js/key.html – Tim Down Jun 20 '11 at 22:06
-
You're right, @Tim, regarding keypress support - I discovered this later when I looked into it again (I was remembering something incorrectly.) – kinakuta Jun 20 '11 at 22:16
1 Answers
1
Here are a couple:
http://habrahabr.ru/blogs/jquery/76424/
http://www.openjs.com/scripts/events/keyboard_shortcuts/
http://wiki.fluidproject.org/display/fluid/Keyboard+Accessibility+Plugin+API
Note that the first is in Russian, but Google Translate does a good job of translating it. translate.google.com
I haven't tried any of them, but haven't seen anyone else suggest anything. Hopefully that gives you a starting point. Good luck!

Calvin Froedge
- 16,135
- 16
- 55
- 61