Advertisement

Please help with keyboard input problem....

Started by October 12, 2002 05:15 PM
2 comments, last by Vampiric_Saviour 22 years, 1 month ago
hi, i am working on a small rpg game ubt i seem to be having trouble reading keyboard input in Visual C++ I have it reading the VK_NUMPAD inputs, but when i try to get anything from the rest of the keys, ie VK_A, it says that it is an undeclared identifier.. could someone please tell me what i am doing wrong and why the numpad keys work, but not the normal keys? thanks for any help on this
Here are the hex ranges of the virtual key codes.

0x30 - 0x39 = Keys 0-9
0x41 - 0x5A = Keys A-Z

Example (Under your WindowProc):
hWnd being the handle to the window.

case WM_KEYDOWN:{    switch (wParam)    {        case 0x41:            MessageBox(hWnd, "You hit A", "WM_KEYDOWN", MB_OK);            break;        case 0x30:            MessageBox(hWnd, "You hit 0", "WM_KEYDOWN", MB_OK);            break;    }//switch    return 0;}//WM_KEYDOWN 


I Hope this helps you with your problem.


[edited by - Shadow Wolf on October 12, 2002 6:42:27 PM]
Advertisement
GetAsyncKeyState(VK_NUMPADWHATEVER)
GetAsyncKeyState(''A'')
GetAsyncKeyState(''B'')
etc.
thanks guys...

I shall give those a whirl.. see if i can clear up this problem

This topic is closed to new replies.

Advertisement