I have a web page and I need to intercept all keypresses before they get dispatched to whatever element in the dom has the focus. When the user types something like ~
You will probably have better luck with keydown it should fire before the event
also do this
$(document).keydown(function(e) {
e.preventDefault();
});
calling preventDefault will stop normal process of the key press. Actually, you may be able to stay with keypress and just use the preventDefault to finish your interception needs.