Netshine Software Limited







Home arrow Developer Blog Make Text BiggerMake Text SmallerReset Text Size
Category >> onkeydown

Jun 04
2009

keydown, keyup, keypress not fired on non-input elements

Posted by netshine in onkeyuponkeypressonkeydownkeyupkeypresskeydownJavascripthtmlformsfocusfiredeventcross browsercapture

If you want to capture one of the above events in javascript, in most cases, it will be on an input element (eg. a text box). But what if you want to capture a keypress anywhere on a document (eg. to delete a highlighted element from the page when the delete key is pressed, which is what I was trying to do)? I tried adding onkeydown to the body tag, but it would only fire in IE. Firefox, Safari, Chrome, and Opera all failed to fire the event unless I first clicked on a text box. But there is a way to do it...

Joomla! Tutorial
Take a look at our free tutorial for Joomla! Administrator...


Login Form





Lost Password?

© 2004-2010 Netshine Software Limited   Terms and Conditions