Jump to content
  • Advertisement

Archived

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

SelethD

Getting a keypress from windows

This topic is 5311 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

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
Advertisement
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
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
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

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!