If i want handle the WM_KEYDOWN for two bottons...?

Started by
11 comments, last by Link 21 years, 2 months ago
When you''re using WM_KEYDOWN you will NEVER get two keys at the same time, you will always get one after the other.

If you don''t want to look inside GetAsyncKeyState and want to stick with WM_KEYDOWN, then you have to implement some buffering.

Take a bool array of 256 entries (for sure), and in WM_KEYDOWN set the corresponding entry to true, and in WM_KEYUP to false.

So in WM_KEYDOWN you set your array entry and after that you can check your array for pressed keys.

This is not the best solution, and not optimal either, but it will work. (I suggest DirectInput, if it is an option to you).

Regards,
Endurion

Fruny: Ftagn! Ia! Ia! std::time_put_byname! Mglui naflftagn std::codecvt eY'ha-nthlei!,char,mbstate_t>

Advertisement
Can u give me some others suggests abaut GetAsyncKeyState?

what is the best solution?
call your input function every loop while passing in the message parameters.

bool keyUp;
void OnKey(DWORD wParam, UINT message, DWORD lParam)
{
switch( wParam )
{
case VK_UP:
keyUp = (WM_KEYDOWN == message);
break;
case VK_DOWN:
keyDown = (WM_KEYDOWN == message);
break;
}
}

This way your bool will always hold the correct value for the key. It's what i've been using for a while anyhow.

return Neff;

[edited by - neff on February 10, 2003 4:53:05 PM]

This topic is closed to new replies.

Advertisement