Created
April 19, 2017 16:06
-
-
Save wwwjsw/7b9dea84df8792e0a79e2ac5560cac95 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //setup before functions | |
| var typingTimer; //timer identifier | |
| var doneTypingInterval = 5000; //time in ms, 5 second for example | |
| var $input = $('#myInput'); | |
| //on keyup, start the countdown | |
| $input.on('keyup', function () { | |
| clearTimeout(typingTimer); | |
| typingTimer = setTimeout(doneTyping, doneTypingInterval); | |
| }); | |
| //on keydown, clear the countdown | |
| $input.on('keydown', function () { | |
| clearTimeout(typingTimer); | |
| }); | |
| //user is "finished typing," do something | |
| function doneTyping () { | |
| //do something | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment