|
Jun 04
2009
|
keydown, keyup, keypress not fired on non-input elementsPosted by netshine in onkeyup, onkeypress, onkeydown, keyup, keypress, keydown, Javascript, html, forms, focus, fired, event, cross browser, capture |
|
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...



Developer Blog 

