Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
116
rated 0 times [  122] [ 6]  / answers: 1 / hits: 23189  / 15 Years ago, fri, june 26, 2009, 12:00:00

I'm designing a web site and I would like to be able to call a function 1 second after the last user input. I tried using onKeyUp, but it waited 1 second after the first keystroke.



Does anyone know how would this be possible?


More From » html

 Answers
3

Another similar approach, without globals:



var typewatch = function(){
var timer = 0;
return function(callback, ms){
clearTimeout (timer);
timer = setTimeout(callback, ms);
}
}();


...



<input type=text onKeyUp=typewatch(function(){alert('Time elapsed!');}, 1000 ); />


You can this snippet here.


[#99239] Monday, June 22, 2009, 15 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
ignacio

Total Points: 467
Total Questions: 128
Total Answers: 79

Location: Luxembourg
Member since Tue, Mar 14, 2023
1 Year ago
ignacio questions
;