<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()" />