C++ Arrow Keys
-
For a windows program I am making I need to detect arrow key presses. Now I have a switch statement: switch(nChar) { case VK_DOWN: // do stuff break; case VK_RIGHT ... } but I need to detect if multiple arrow keys are being pressed at once, how can I do this? (my OnKeyDown handler no longer does anything when a key is pressed. I'm not sure but it might be it doesn't have the focus, though I actually have no idea. Any ideas on that?) Any help is greatly appreciated. Thanks.
-
For a windows program I am making I need to detect arrow key presses. Now I have a switch statement: switch(nChar) { case VK_DOWN: // do stuff break; case VK_RIGHT ... } but I need to detect if multiple arrow keys are being pressed at once, how can I do this? (my OnKeyDown handler no longer does anything when a key is pressed. I'm not sure but it might be it doesn't have the focus, though I actually have no idea. Any ideas on that?) Any help is greatly appreciated. Thanks.
>> I need to detect if multiple arrow keys are being pressed at once, how can I do this? Reading the documentation is always the place to start http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/WinUI/WindowsUserInterface/UserInput/KeyboardInput/KeyboardInputReference/KeyboardInputMessages/WM_KEYDOWN.asp[^]
"No matter where you go, there your are." - Buckaroo Banzai
-pete
-
>> I need to detect if multiple arrow keys are being pressed at once, how can I do this? Reading the documentation is always the place to start http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/WinUI/WindowsUserInterface/UserInput/KeyboardInput/KeyboardInputReference/KeyboardInputMessages/WM_KEYDOWN.asp[^]
"No matter where you go, there your are." - Buckaroo Banzai
-pete
I have taken a look at that, but this time I noticed I need to give my view the keyboard focus (how can I do this?). Thanks. Though I'm still not sure how to detect multiple arrow key presses at once, I tried getting the flags with "ah 12h, int 16h" but that only returns flags that hold shift,ctrl,insert,etc. So how do I detect that two (or more) arrow keys are being pressed at once?
-
For a windows program I am making I need to detect arrow key presses. Now I have a switch statement: switch(nChar) { case VK_DOWN: // do stuff break; case VK_RIGHT ... } but I need to detect if multiple arrow keys are being pressed at once, how can I do this? (my OnKeyDown handler no longer does anything when a key is pressed. I'm not sure but it might be it doesn't have the focus, though I actually have no idea. Any ideas on that?) Any help is greatly appreciated. Thanks.
Take a look at the function
GetKeyState(VK_DOWN)
, should return the state of the key, pressed or not etc. You will need to call it once for each key you want to check. If you vote me down, my score will only get lower