js function call only when tryping paused 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: search when user stops typing
let input = document.getElementById('my-input');
let timeout = null;
input.addEventListener('keyup', function (e) {
clearTimeout(timeout);
timeout = setTimeout(function () {
console.log('Input Value:', textInput.value);
}, 1000);
});