how to know if stopped typing code example
Example 1: stopped typing jquery
var timer = null;
$('#text').keydown(function(){
clearTimeout(timer);
timer = setTimeout(doStuff, 1000)
});
function doStuff() {
alert('do stuff');
}
Example 2: call function after few sec of input type
var typingTimer;
var doneTypingInterval = 5000;
var $input = $('#myInput');
$input.on('keyup', function () {
clearTimeout(typingTimer);
typingTimer = setTimeout(doneTyping, doneTypingInterval);
});
$input.on('keydown', function () {
clearTimeout(typingTimer);
});
function doneTyping () {
}