Getting a keypress from windows

Started by
3 comments, last by SelethD 20 years, 3 months ago
How does one get a keypress when working in a windows application? in my message loop, i check UINT msg and if its WM_KEYDOWN i then check wparam and it gives me the virtual key code, VK_A but i need ascii so i can tell if it is lowercase or uppercase I had a book that told me how, but I have lost the book and forgotten what to do. Please help
Advertisement
wParam itself is ASCII. To get the ASCII number just cast wParam to an int [int(wParam)].
i dont think it is, i get the value 65 for both lower and upper case A

i did this

int key;

key = (int) wparam;

printf("%d",key);

came to 65 with both a''s
and 15 when i hit the shift key, before pressing the a key

so this is giving me the virtual keycode (windows version of scancode)

please help anyone
Problem fixed, reading a few other posts on here, i see what im doing wrong.

wparam holds the ascii value, only if you read wparam after msg sends a WM_CHAR command.
I was polling a WM_KEYDOWN message.
If you use TranslateMessage() properly you should get a WM_CHAR message for every WM_KEYDOWN message generated. The wParam of the WM_CHAR message should be the ASCII value of the key pressed.

edit: and you figured it out right before I posted

[edited by - SiCrane on January 5, 2004 9:25:50 PM]

This topic is closed to new replies.

Advertisement