Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Programming Talk / C++ / C# - How do I detect key combinations in win32 api.

Author
Message
coolgames
19
Years of Service
User Offline
Joined: 26th Sep 2005
Location: Oregon, USA
Posted: 15th Oct 2009 07:00
How should I go about detecting key combinations in the win32 api. Such as ctrl-z. Are there special messages associated with the combinations? What is the best way to detect these?

Thanks,
Coolgames
Bruce Dudeson
16
Years of Service
User Offline
Joined: 17th Mar 2009
Location:
Posted: 17th Oct 2009 11:34 Edited at: 17th Oct 2009 11:38
You can use the GetAsyncKeyState function

an example of checking for ctrl-z would be:

if (GetAsyncKeyState(VK_CONTROL) && GetAsyncKeyState(0x5A))
{
// do something
}

Here's a link of all the virtual key codes:
http://msdn.microsoft.com/en-us/library/ms645540%28VS.85%29.aspx
coolgames
19
Years of Service
User Offline
Joined: 26th Sep 2005
Location: Oregon, USA
Posted: 17th Oct 2009 18:59
That sounds good. I'll try using that.

Thanks!
Bruce Dudeson
16
Years of Service
User Offline
Joined: 17th Mar 2009
Location:
Posted: 17th Oct 2009 23:29
No problem, glad I could help

Login to post a reply

Server time is: 2025-05-17 06:04:18
Your offset time is: 2025-05-17 06:04:18