You can use a global timer variable.
var tim;
function onKeyDown()
{
if (tim != null)
clearTimeout(tim);
tim = setTimeout('TimerUp()', 2000);
//do key work here
}
function TimerUp()
{
//do timer work here
}
You have an answer, but I suggest you consider the problem domain before
solving in this manner. Most likely, you are either a) wanting to allow for
corrections or b) wanting to wait until the entire string is entered before
processing.
If a, your method might be the best, depending on what you are doing. If b,
you can process the portion that fits the keystroke and then capture the
blur event for the control to do complete processing. This will help you
avoid the wait two seconds.
I know nothing of your app, but I did a heavy JavaScript app years ago for
key entry (replace a windows app). If I would have waited two seconds, I
would have been hosed. Your app is, hopefully, completely different.

Signature
Gregory A. Beamer
MVP, MCP: +I, SE, SD, DBA
Subscribe to my blog
http://gregorybeamer.spaces.live.com/lists/feed.rss
or just read it:
http://gregorybeamer.spaces.live.com/
*************************************************
| Think outside the box!
*************************************************
> hey all,
> i have a key up javascript function where i want half the function to run
[quoted text clipped - 6 lines]
> thanks,
> rodchar