Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


VK_0 - VK_9 won't work!

This topic is 6623 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

VK_0 - VK_9 and VK_A - VK_Z do not WORK, because they do not exist. For some unknown reason Microsoft decided that since VK_0 maps directly to the ASCII ''0'' and VK_A to ''A'', that you can just as easily use those constants directly instead of the VK_ style definitions. I found this out only a few months ago (when i switched from translated to untranslated keyboard messages) and still find it very strange that they choose not to include the simply defines in their SDK header files. BTW, you can simply create a header file yourself using a simple #ifndef / #define / #endif structure, that way you can use consistent VK_ switch cases. Good luck

Share this post

Link to post
Share on other sites
Oh yeah, just for those who may not understand the issue. Some of Microsofts examples DO use VK_0 and VK_A etc... and the header file "winuser.h" included with Visual C++ 6 actually contains a comment stating the solution I posted above.

[for those curious, the way I found how to use VK_0 was to do a find-in-files search on the VC include directory for it - this trick is helpfull with very many SDK or C++ programming issues]

happy hunting

Share this post

Link to post
Share on other sites
I dont know if you are still searching for a solution to your problem.

You can use these standard API functions (GetKeyState() and VkKeyScan() )

#define KEYDOWN(vkey) ((GetKeyState(vkey)>>15))

#define CHDOWN(ch) (KEYDOWN(VkKeyScan(ch)))

So you can use KEYDOWN() for virtual keys (like VK_SHIFT, VK_UP,...) and use CHDOWN() for ASCII characters (like '0', 'a',...)
If the key is pressed they returns 1 (TRUE) else 0 (FALSE).

Edited by - Andrea on September 2, 2000 6:25:32 PM

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!