Dark Bit Factory & Gravity
PROGRAMMING => Freebasic => Topic started by: Clyde on September 13, 2006
-
I wonder if anyone knows how to make it so that when you press a key using GetAsyncKeyState() that it doesnt make things happen so quickly when a key is pressed?
Dummy example:
If (GetAsyncKeyState(68)) Then Debug=Debug+1
If Debug>1 Then Debug=0
If Debug Then
'Display Info
End If
Cheers and many thanks,
Clyde.
-
Try this one it will work fine ;)
If ( GetAsyncKeyState(68) = -32767 ) Then Debug=Debug+1
If Debug>1 Then Debug=0
If Debug Then
'Display Info
End If
-
Cheers for that buddy.
-
Because GetAsyncKeyState returns two values at once. 0x8000 if the key is currently pressed and/or 0x0001 if the key was pressed since the last time you called GetAsyncKeyState. Rbraz's -32767 is, in fact, 0x8001 (&h8001 in basic).
Jim
-
This function is very useful, I was messing with it yesterday and came on to post the very same question you did Clyde so I guess I got the fastest answer ever. :)