...

View Full Version : keydown repeat



Bobo
01-20-2005, 08:20 PM
I have a keydown event that starts a timer and clears it onkeyup.
The problem is that when you hold down the key, it acts like you're typing and repeats so rapidly that the timer clears before it calls.
This is the actual code:


var tm1;
function Move(....)
{
...
}
function srt(evt)
{
tm1=setInterval("Move("+event.keyCode+")",100);
....
}
function end()
{
clearInterval(tm1)
}
document.onkeydown=srt;
document.onkeyup=end;

Any ideas on how to prevent the repeat or fix the code for it to not accept the rapid repeats?

codegoboom
01-21-2005, 12:56 AM
Try setting a variable to true onkeydown, false onkeyup, and then put an if(!var) setInterval, or something...

Bobo
01-21-2005, 09:12 PM
Good idea!
Tried it... works... thanks! :D



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum