Jump to content
  • Advertisement
Sign in to follow this  
VprMatrix89

Win API - Virtual Keys

This topic is 3664 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I looked up the virtual keys and found that the keyboard number 1 is represented by a hexadecimal value of '30' in windows api. Using windows procedure how do I type this in?

Share this post


Link to post
Share on other sites
Advertisement

if ( GetAsyncKeyState(30) )
{
foo();
}


will do foo(); if 1 is pressed when the function is called

Share this post


Link to post
Share on other sites
Your question doesn't make much sense. I'm guessing you don't know how to use hex numbers in C/C++? Something like this:
if (vk == 0x31) whatever();    // 1 is hex 31, not 30

For the specific context of virtual keys it's probably clearer to this instead:
if (vk == '1') whatever();

For number and letter keys you can just use a character constant like that (use uppercase for letters, i.e. 'A'). For other keys you can use one of the standard VK_ constants. Some people also like to create VK_ constants for numbers and letters for consistency since the standard Windows headers don't do that themselves for some reason.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!