Re: Need advice for acting on only the last onkeyup event in a series
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.javascript archive

Re: Need advice for acting on only the last onkeyup event in a series

From: <john.lum@gmail.com>
Date: Tue Jan 31 2006 - 14:25:24 CET

Thanks much for the suggestion. Your approach didn't quite work for
me; it did not achieve the desired result of deferring response action
until the "final" keypress prior to a delay of at least 500 ms.

However, I did get things working with a modified version that uses
global variables:

//--------------
var keyCount = 0;
var timeoutCount = 0;

function handleKeyUp() // keyup handler
{
    keyCount++;
    setTimeout("compareCounts()", 350);
}

function compareCounts()
{
  timeoutCount++;
  if (keyCount == timeoutCount)
  {
    // my processing goes here
  }
}
//--------------

There may be better/non-global-variable techniques involving passing
function references to the setTimeout function, but I will settle for
quick and dirty.

Thanks,
John
Received on Tue Feb 7 21:28:42 2006