Archived

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

keyboard input

This topic is 5115 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''m using the following macros from a Lamothe book: #define KEY_DOWN(vk_code) ((GetAsyncKeyState(vk_code) & 0x8000) ? 1 : 0) #define KEY_UP(vk_code) ((GetAsyncKeyState(vk_code) & 0x8000) ? 0 : 1) These work on all keys like ctrl, home, shift, end, return, etc., but when I try something like: KEY_DOWN(VK_P); I get the error: error C2065: ''VK_122'' : undeclared identifier How do I use the alphanumeric keys to test for input?

Share this post


Link to post
Share on other sites
I forgot to mention Im using VC++6 and DirectX 7.0. I intend to use DIrectInput in the future, but until then, I''d like to get by with these macros. Thanks for your help.

Share this post


Link to post
Share on other sites
I''m not 100% for certain, but I believe Lamothe mentions that there are not any VK_ constants defined for the alphabetical keys, so I don''t think there is a VK_P defined. Also, I don''t believe there are VK_ constants defined for the keys 0-9 either.

Share this post


Link to post
Share on other sites
Apparently, there are no virtual key codes for the alphanumerics. You use the ASCII values for the keys:
KEY_DOWN(80); //''P'' pressed

I tried using the character, and that worked as well:
KEY_DOWN(''P'');

thanks for the help.

Share this post


Link to post
Share on other sites
No problem. I was just about to post saying the same about being able to use the a numeric value rather than a keycode constant. I found this link on MSDN giving a list of the possible virtual-key codes and their hexadecimal equivalents. Thought you may wanna take a look at it.

Share this post


Link to post
Share on other sites