Reputation: 43
I've been using GetAsyncKeyState(int vKey) for my input in a game. I have two questions? A.) Is it very efficient or is there something else that handles keyboard input better? B.) How can I limit the key to be sensed once. - I imagine it would be something like
// Psuedocode
prevState = currentState
currentKeyState = GetAsyncKeyState
if(currentKeyState(whatever key I want) && !prevKeyState(whatever key I want))
Clear currentKeyState
I tried to do something like that and it doesn't really work. Should I use some sort of timing thing? I just would like someone to show me or lead me in the right direction?
Upvotes: 0
Views: 927
Reputation: 8587
You could set a boolean switch to make sure that if the KEYDOWN
event is TRUE
or has already ocurred then do not treat it as a valid key press etc etc..
if(GetAsyncKeyState(VK_DELETE))
{
if(hack)hack = false; // if true set to false
else hack = true; //if false set to true
cout<<"Hack set to: " << hack <<endl;
}
Read this post : http://www.mpgh.net/forum/showthread.php?t=120656
Upvotes: 0