Disabling key hold-downs. PLEASE HELP

Okay now that i’ve got your attention.

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??

Thank you!

You might want to invest some time in researching DirectInput. That’s probably the best way to go about it.

this has nothing to do with opengl.
im still trying to figure out how dinputs gonna help

you could use the window messages
or do someit like (works on the principle a key is pressed until its not pressed)

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

This code will do it:

case WM_KEYDOWN:
{
// check if key was pressed (opposed to held down)
if (!(lParam & 0x40000000))
keys[wParam] = TRUE;
return 0;
}

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.