html - How to hook a keyboard event handler onto an INPUT element with jQuery? -
i want attach own key event handler input has event handler attached onkeydown
. essentially, want receive key event before other handlers , check if user pressed key -- if yes, want perform functions , discard event, if no, want pass along other handler(s).
how can jquery?
if loading 3rd party script or jquery addon can load script or function first. if can use without mess of unbinding , rebinding event handlers.
// possible interceptor code $("#awesome").keydown(function(e) { if (e.keycode < 70) { e.stopimmediatepropagation(); console.log("blocked!!!"); }; }); // possible 3rd party event code loaded after code $("#awesome").keydown(function(e) { console.log("3rd party:"+e.keycode); });
example webpage => http://mikegrace.s3.amazonaws.com/forums/stack-overflow/example-key-event-interception.html
example output of firebug console
Comments
Post a Comment