Win API - Virtual Keys
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?
if ( GetAsyncKeyState(30) ){ foo();}
will do foo(); if 1 is pressed when the function is called
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:
For the specific context of virtual keys it's probably clearer to this instead:
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.
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.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement