I’m looking to learn how to build something that detects key-presses in order to throttle a function.
Something like:
var LastKeyPress;
function hitTheServer() {
if LastKeyPress > 2 seconds ago {
hit the server and do stuff
LastKeyPress = now();
}
}
What do you think? Maybe this is built into jQuery? Also, its something that I’d likely use for many functions, and it could be interesting to have this working globally, so I can use less code and apply to several functions. Thoughts?
Thanks
You might check out Ben Alman’s jQuery throttle / debounce plugin