Detecting Key Combination
-
Hi, I am sure this is an easy one, but I cannot get this information intercepted. I have an Edit View and want to know when the user presses space whilst the left ctrl key is held down. Is this possible? Thanks in advance, Simon
3 ways I can think of do do this: 1) Create an accelerator and handle it in your view class. 2) Overide the WM_KEYDOWN message and check for the space key and call GetAsyncKeyState (or is it GetKeyState) to see if the control key is down. 3) Overide the PreTranslateMessage function, check for WM_KEYDOWN and do step 2.
-
3 ways I can think of do do this: 1) Create an accelerator and handle it in your view class. 2) Overide the WM_KEYDOWN message and check for the space key and call GetAsyncKeyState (or is it GetKeyState) to see if the control key is down. 3) Overide the PreTranslateMessage function, check for WM_KEYDOWN and do step 2.
Hi Matt, Thanks for the response, you put me in the right place! I handle WM_KEYDOWN already, so I elected for option 2, and you are right to mention GetKeyState. It works when I do the following: if((nChar == 32) && (GetKeyState(VK_CONTROL) >> 7) == -1)) { // it happened } Is this how you would expect to do it? Simon