keyboard input

Started by
3 comments, last by R67en 20 years, 4 months ago
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?
Advertisement
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.
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.
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.
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.

This topic is closed to new replies.

Advertisement