I have a keypress
handler on a web page assigned to the body element. I really do want it to be active anywhere in the web page. Or so I thought. The k
It would be easier simply to check which element triggered the event in your keypress handler and filter out input elements:
document.onkeypress = function(evt) {
evt = evt || window.event;
var target = evt.target || evt.srcElement;
if ( !/INPUT|TEXTAREA|SELECT|BUTTON/.test(target.nodeName) ) {
// Do stuff
}
};