On my site I have registered a keypress event handler for the whole document.
$(document).keypress(myhandler);
And I handle the ‘space’ key to scroll a list.
Trouble is, there is an <input type='text' /> element, and I don’t want ‘space’ keypress to scroll the list when it is entered in the input.
I couldn’t find any information in the “event” object passed by JQuery to the handler, to identify where the source of the event is.
Alternatively, you could attach another event handler to the input field, and in this handler stop the propagation of the event:
This way, you can leave the global event handler as it is. Might be cleaner.