Hello
I need for my little game key input. Unfortunately I dont need only arrows but even letters. Is there any way how to do so using only WinAPI or do I need to use DirectX?
Hello
I need for my little game key input. Unfortunately I dont need only arrows but even letters. Is there any way how to do so using only WinAPI or do I need to use DirectX?
Simply handle the WM_CHAR or WM_KEYUP/WM_KEYDOWN messages for your window.
for games its generalyl preferred to use the WM_KEYUP and WM_KEYDOWN messages to update a keystate structure. WM_CHAR is subject to auto-repeat for keys that are held down. One thing to note however is that if the application loses focus while a key is down adn then the player releases the key while th app doesnt have focus, then the app will not recieve the WM_KEYUP message and will think that the key is still down. You should occasionally perform a sanity check using GetAsyncKeyState() for keys that are held down for lengthy periods. Dependign ont eh game, you coudl of course just skip that step, as it may not be an issue.
So now I use GetAsyncKeyState() for any input again thx for the advice. Just additional question I found at MSDN list of virtual keys but they dont work in my app the values are different. Is it because my app is set to Multibyte so that the character set has different mapping values?
If yes where can I see map of Multibyte character set?
Oh I didnt realize before what I was looking for is a table of ascii code.
Oh wow... Well if you ever need it, check out the VK_* codes on MSDN.