hi,
I'm trying to make a game and i need to get keystrokes. I cannot use getchar() because it needs an enter after the character is typed.
You need to process the WM_CHAR message to read keyboard input.
if you use console, try _getch(), include conio.h
Thanks timovjl, _getch() works as I wanted,
but it returns 224 for all of the arrow keys. I can use other keys but is there a way to use arrows.
Quote from: nima on March 28, 2011, 10:09:41 PM
Thanks timovjl, _getch() works as I wanted,
but it returns 224 for all of the arrow keys. I can use other keys but is there a way to use arrows.
Some keys return two characters... so you need to check the first to see if it's an "arrow key" then deal with the second character to find out which one it is...
Something to the effect of ... if (first key == 224 ) get second key...
Thanks a lot CommonTater.
Problem solved :)
i am just curious- how to get the second key?
Quote from: abhas on April 09, 2011, 05:00:24 AM
i am just curious- how to get the second key?
Call getchar() again.
if (key == 224)
key = GetChar();
It might be a bit more complex than that, I don't recall offhand if the second character value overlapps the regular key values... but a bit of experimentation will give you the answer.
8) ;D o got it.