I have an input on an HTML page where a person will type something and what I'm wanting is for a function to be called every time they stop typing. I know about the onkeypress event, but that is called every time a character is typed. Here's an example of what I would like:
Is this possible?
Thanks a lot!
Listen to onkeyupevent. There start a timeout (you have to define "stop" as some time amount, otherwise it will be called at every keyup), and in the timeout execute your function.
If onkeydown is called while your timer is running, stop it.
Something like...
var timer;
function onKeyUpHandler(e){
timer = setTimeout("foo()", 500)
}
function onKeyDownHandler(e) {
clearTimeout(timer);
}
How this code exactly looks depends where and how you are using it... just to show the way to do it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With