I'm new to c++ and wondering what "WM_KEYDOWN" is? And how to use it.
Thank you.
I'm new to c++ and wondering what "WM_KEYDOWN" is? And how to use it.
Thank you.
WM_KEYDOWN
is defined in Microsoft Docs:
#define WM_KEYDOWN 0x0100
While I don't have a better explanation than Microsoft's, I'll post what the doc says:
Posted to the window with the keyboard focus when a nonsystem key is pressed. A nonsystem key is a key that is pressed when the Alt key is not pressed.
Simply put, it is a value returned by Windows in a program when a key on the keyboard is pressed (and when Alt isn't). The opposite is WM_KEYUP
, which will be emitted when you release the key.
A message flag produced by your window when your key is pressed. You can use it in the message handler function like
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
Then register it to your WNDCLASS
WNDCLASS ws;
ws.lpfnWndProc = WndProc;
See http://msdn.microsoft.com/en-us/library/gg153546(v=VS.85).aspx for more information about how to dual with WM_KEYDOWN in WndProc.