Skip to content

Instantly share code, notes, and snippets.

@rblakejohnson
Created December 11, 2013 18:36
Show Gist options
  • Save rblakejohnson/7915937 to your computer and use it in GitHub Desktop.
Save rblakejohnson/7915937 to your computer and use it in GitHub Desktop.
delay action on keypress to improve performance
var i = 0;
$('input').keypress(function() {
if (this.timeoutId) {
window.clearTimeout(this.timeoutId);
}
this.timeoutId = window.setTimeout(function () {
// do something
}, 200);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment