I want to know how to do key events in windows programming.


Hello ,

I am new to windows programming. I want to know how to do the key_events in windows like vk_left ,vk_right,vk_up, vk_down . In which function do i write it etc.

just give me some sample code.

Thanks.
Look up the WM_KEYDOWN message, which your Window Procedure receives when any of the extended keys are pressed. The documentation will tell you the meaning of the wParam and lParam parameters. So you'll likely have decision logic based on receiving the WM_KEYDOWN Windows message, then further logic to act on which notification, i.e., VK_UP, VK_DOWN, etc.
You need to have a Window to handle Keys in the common way.
You can also use GetAsyncKeyState if you don't have a Window: http://msdn.microsoft.com/en-us/library/windows/desktop/ms646293(v=vs.85).aspx
Topic archived. No new replies allowed.