javascript wait for user to stop typing
/*this will delay the doneTyping function
until 1 second after the user stops typing*/
var isUserTypingTimer;
var doneTypingInterval = 1000;// wait for 1 second b4 sending requests
function doneTyping () {
//make request here
}
document.getElementById("myInput").addEventListener('keyup', function(event){
clearTimeout(isUserTypingTimer);
isUserTypingTimer = setTimeout(doneTyping, doneTypingInterval);
});
document.getElementById("myInput").addEventListener('keydown', function(event){
clearTimeout(isUserTypingTimer);
});