Sign in to follow this  

GetKeyState() problem

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

I'm having some trouble getting GetKeyState() to work properly. I need it to detect letters and numbers, which it's not doing. It detects the enter key, caps lock, shift, tab, etc but nothing for letters and numbers. Here's what I'm doing..

void HVSTInput::CkeyboardTrigger::pollKeys()
{
for (int i = 0; i < 128; i++)
{
_keyboard[i]->setKeyState();
}
}


First there's this, which runs from 0 to 127, checking 128 different "keys."

void HVSTInput::CKey::setKeyState()
{
_previousState = _currentState;
_currentState = GetKeyState(_key);
}


Then this just sets the state of the key using GetKeyState, where _key == i from the loop in pollKeys() method. Now I've looked on MSDN which says to use the ascii value for letters and numbers, which is what I thought I was doing here. Yet, only the keys that I mentioned above are actually triggering.

Share this post


Link to post
Share on other sites
For numbers make sure you are checking for '9' instead of 9

For letters, if you have been trying lower case, try upper case. If you have been trying upper case try lowercase.

Also there might be some good info here for you (:

http://www.gamedev.net/community/forums/topic.asp?topic_id=24296

Share this post


Link to post
Share on other sites

This topic is 2627 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this