Jump to content
  • Advertisement


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


Question regarding characters

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

Hi! Im reading wm_keydown and wm_char. But I got this problem.. I want to read other keys than the usual a-z 1-9. But I found that not all keys correspond to the ASCII chart for instance, if I press button "a" (ascii 97) - I get a big "A" (ascii65) instead. if I press "." (ascii 46) wparam returns 190 I''ve read about wm_keydown and wparam at msdn, and it says "wParam - Specifies the virtual-key code of the nonsystem key." It didn''t say how to fix the problem really... I have seen many applications reading these keys, including å ä ö among others.. is there an easy way around this?

Share this post

Link to post
Share on other sites
On the assumption that key holds the keycode returned from the windows message, use this bit of code...

// need an array to hold all of the keystates....

unsigned char pKeys[256];
// get the keyboard state for the ToAscii function

// variable to hold the ascii code...

unsigned short pRet = 0;
// get the ascii key code...

// convert to char...

char asciiCode = (char)pRet;

Share this post

Link to post
Share on other sites
Thx! that seems to work just as I want ("a" gets 97). Only thing is that (char)pRet gets 246 when I type "ö". Char "ö" is right, but code 246? :/ According to my ascii tables "ö" is 148.

[edited by - Herr_O on August 27, 2002 12:12:53 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!