Event Keyup a-z key response

19 views
Skip to first unread message

kstubs

unread,
Jul 9, 2011, 4:40:47 PM7/9/11
to prototype-s...@googlegroups.com
Is there a clever way to ignore all other keystrokes, like arrow keys and only responsd to keycodes ranging from a-z and 0-9?  I guess another valid keystroke would be SHIFT+<a-z>.  So something like:

onKeyUp: function(e) {

  // if not valid keystroke event
  return;

  // otherwise, do the following code
}

Victor

unread,
Aug 2, 2011, 6:49:02 AM8/2/11
to prototype-s...@googlegroups.com
Check e.keyCode. For numbers it should be in range 48...57, for letters a...z in range 97...122 (for Shift-a..z also 97...122, so you need extra check for Shift key). Other way is to use onkeypress event - it will have proper codes for a...z and A...Z, but is more browser-specific even with Prototype.
Reply all
Reply to author
Forward
0 new messages