I use the WM_KEYDOWN message(by checking wParam for a specific key of course) in my application to start an animation and use the WM_KEYUP message to tell when the key is released and stop the animation.
But Windows have that autorepeat feature and when the key is preesed continuously many WM_KEYDOWN messages are received before an KEYUP message resulting my animation start again and again.
How can I get rid of this?
Thanks for help in advance!
You can't. Check for the first message, set a flag, wait for keyup and reset the flag.
Thanks for reply. I came up to the following:
The keys array will be initialized to false.
BOOL keys; // Flags for all keys
The WM_KEYUP handler:
The WM_KEYDOWN handler:
keys[wParam] = FALSE;
if(keys[wParam] == FALSE)
keys[wParam] = TRUE;
// The key is pressed for the first time
/* ..... .... */
// Key is already pressed pressed. Skip....