Archived

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

SelethD

Getting a keypress from windows

Recommended Posts

SelethD    456
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

Share this post


Link to post
Share on other sites
SelethD    456
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

Share this post


Link to post
Share on other sites
SelethD    456
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.

Share this post


Link to post
Share on other sites
SiCrane    11839
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]

Share this post


Link to post
Share on other sites