$('#my_input').keyup(function(){ alert("Hello!"); });
<script type="text/javascript"> window.onload = function() { function foo() { alert("Don't stop typing!"); t = setTimeout(arguments.callee, 2000); } var t = setTimeout(foo, 2000); document.getElementById("my_input").onkeyup = function() { if (t) clearTimeout(t); t = setTimeout(foo, 2000); } } </script> <input type="text" id="my_input" />
<script> function say() { alert("Печатай!"); }; run_id = false; function wait_and_say() { run_id= setTimeout(say, 2000); }; function cancel_say() { if (run_id) clearTimeout(run_id); run_id= false; }; </script> <input onkeyup="wait_and_say()" onkeydown="cancel_say()" />
run_id; (function cancel_say() { clearTimeout(run_id); })()