Problem with getche()
For some reason my first post was empty.
Anyway, I'm having a problem with getche() and GetAsyncKeyState(). I use getche() to store the pressed key in a string and use GetAsyncKeyState() to check what key I pressed. But when I press one of the arrow keys, it adds two characters to the string (ZERO character and P if I pressed down) even when .length() says it added just one. When I then try to remove those characters from the string with .erase() I can only get rid of the ZERO character. When I then print the string the second character is always there messing things up.
I've even tried to do the checking first and adding the key to the string afterwards if none of the arrows was pressed but it's still there haunting.
Is there a way to get rid of that second character? Or is there another way to save the pressed key to a string than getch()/getche()?
It sounds like you're having problems with the extended character codes. Check the FAQ for possible solutions.
I checked the FAQ again but there is nothing there that can help me. As far as I know, GetAsyncKeyState() is the only way to check if one of the numpad keys was pressed and I need to use those keys for other things.