JAVASCRIPT 20
Anction when user finishes typing Guest on 13th September 2020 12:29:33 PM
  1. //setup before functions
  2. var typingTimer;                //timer identifier
  3. var doneTypingInterval = 5000;  //time in ms, 5 second for example
  4. var $input = $('#myInput');
  5.  
  6. //on keyup, start the countdown
  7. $input.on('keyup', function () {
  8.   clearTimeout(typingTimer);
  9.   typingTimer = setTimeout(doneTyping, doneTypingInterval);
  10. });
  11.  
  12. //on keydown, clear the countdown
  13. $input.on('keydown', function () {
  14.   clearTimeout(typingTimer);
  15. });
  16.  
  17. //user is "finished typing," do something
  18. function doneTyping () {
  19.   //do something
  20. }

Paste is for source code and general debugging text.

Login or Register to edit, delete and keep track of your pastes and more.

Raw Paste

Login or Register to edit or fork this paste. It's free.