Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > Seeking robust cross-browser keyboard event handler

Reply
Thread Tools

Seeking robust cross-browser keyboard event handler

 
 
Matt Kruse
Guest
Posts: n/a
 
      08-15-2006
I am seeking an example of a robust keyboard-event-handling strategy that
will work cross-browser and capture as many keys as possible.

As most of you probably know, there are difficulties because some keys are
captured onkeydown and some onkeypress, for example, and the codes returned
by each may be different even for the same key. Further, mozilla browsers
may return different values for keyCode and charCode. The problem has been
identified in various web sites (like quirksmode) but I've not found a
single approach which handles as many cases as possible.
(For reference, I don't care to support ancient browsers like NN4)

As an example, consider a textarea. I would like to be able to capture any
key press, arrow press, tab, enter, escape, F1-F12 (if possible), etc. As an
output, I just want the character pressed to be passed to a handling
function - either "a" or "A" or "ESC" or "TAB" so that I can take action on
that key.

Does code already exist which handles as many conditions and
browser-differences as possible? Keyboard event handling is not something
I've ever ventured very far into, so I'm learning some of these quirks as I
go...

Thanks!

--
Matt Kruse
http://www.JavascriptToolbox.com
http://www.AjaxToolbox.com


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Event Handler that creates adds another event handler kaczmar2@gmail.com ASP .Net 1 02-22-2007 07:37 AM
problem in changing the actual event handler into our own event ashok.dhananjeyan@gmail.com Javascript 0 10-30-2006 02:32 PM
rendering Button inside Render() event, makes it loose its click event handler association sonic ASP .Net 1 01-07-2005 06:33 PM
How to recall add event from an Event handler?? RC ASP .Net Web Controls 1 01-06-2005 07:44 PM
Passing event from dynamically created element and event handler? Adi Javascript 2 02-23-2004 02:44 PM



Advertisments