Basically, set a timeout for each keyboard. If you already have a timeout, clear it and set another. The DoSearch() function is only launched when the timeout is allowed to complete without being reset with another key (that is, when the user stopped typing in 1000 ms).
var timeout = null; $('#SearchInputBox').on('keyup', function () { var that = this; if (timeout !== null) { clearTimeout(timeout); } timeout = setTimeout(function () { DoSearch($(that).val()); }, 1000); });
source share