Game Development Community

Is the scan time too fast?

by BMiuritan · in General Discussion · 12/23/2005 (7:56 am) · 2 replies

Hi all,
I've created a key-combination "f" used to do something. Firstly, its function is too simple:
function DoSomething()
{
echo("You just pressed 'f' key"); // bla lbla.
}

And the thing I got is 2 lines "You just pressed 'f' key" (see in log file). So I don't know why it was executed 2 times. Is the scan time too fast during I pressed once?

#1
12/23/2005 (8:21 am)
A keybind function is executed twice since there is a signal sent when you press a key and when you release it...so what you can do is:

function myKeyBindFunction(%val)  // %val is "1" or "True" when you press the key and "0" or "False" when you release it.
{
     if(%val)
          // do something
     else
          // do something else or skip it altogether and do nothing if you wish
}
#2
12/24/2005 (5:41 pm)
Thanh you Jacob