Im working in a win32 enviroment and have been using the function GetaSyncKeyState() to detect rapid keyboard input. The problem is, when I tap the button, the thing that I want to move, moves too much!!!
How do I make it so It’ll only move one per key-press??
GetaSyncKeyState() is for very fast, asycnchronous monitoring, You probably should use something else, or, only move on a ‘change’ of keystate. Set a flag called ‘PreviousPressed’ or something, and only move if the button is pressed && PreviousPressed is false.
Joe
If you don’t want to use anything as advanced as DirectInput, you could always put some thought into it. GetAsyncKeyState tells if the key is being pressed down, correct? Just keep a flag around that tells what the previous state of the key was. Only move the object if the last call to GetAsyncKeyState showed that the key hadn’t been pressed.