🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Simple Keyboard Input

Started by
5 comments, last by BenB 24 years, 8 months ago
Its been a while since I've done this, but you can use getAsynckeystate... just the constant is something like VK_A for the 'a' key ... etc.
Advertisement
I have tried, but it dosen't work.
Can someone help please?
For virtual keys, VK_A, VK_B, etc, are accurate when using the UIKeyEvent class. However, I am uncertain as to whether or not it is case sensitive... I believe it may be, as it's a direct map to the ascii 0x41 - 0x5A. Perhaps you should try hitting the capslock and seeing if that's your problem.

-fel

~ The opinions stated by this individual are the opinions of this individual and not the opinions of her company, any organization she might be part of, her parrot, or anyone else. ~
Here is how you do it:

//some string variable
char name[256];

//in your winproc
int index;

switch( msg )
{
case WM_CHAR:

index = strlen( name );
name[ index ] = (char)wParam;

return FALSE;

.
.
.

For the letter a use:

GetAsyncKeyState('A')

The variable passed must be a capital letter.
If you want to read capital and lower case you would have to read the shift key.

Good luck with your program


"You know you're obsessed with computer graphics when you're outside and you look up at the trees and think, "Wow! That's spectacular resolution!""
Hello!
I'm using the GetAsyncKeyState(VK_***), but I can't get alphabet, only other Keyboard buttons, like Shift, or the up Button. How can I get alphabet(For example - A) without using DirectInput(I know the way with Direct Input...), and without using the WM_KEYDOWN?
Is there a way?
If you use the WM_CHAR message, the wParam of the message contains the letter correctly capitalized. You need not worry about checking the shift and caps lock keys.

This topic is closed to new replies.

Advertisement