GetAsyncKeyState输入?

时间:2014-05-15 01:08:50

标签: c++ windows input directx

我一直在游戏中输入GetAsyncKeyState(int vKey)。我有两个问题? 答:它是非常有效还是还有其他能更好地处理键盘输入的东西? B.)如何限制一次感知的密钥。          - 我想它会像

// Psuedocode
prevState = currentState
currentKeyState = GetAsyncKeyState
if(currentKeyState(whatever key I want) && !prevKeyState(whatever key I want))

Clear currentKeyState

我尝试做类似的事情并没有真正起作用。我应该使用某种计时的东西吗?我只是希望有人向我展示或引导我朝着正确的方向前进?

1 个答案:

答案 0 :(得分:0)

你可以设置一个布尔开关,以确保如果KEYDOWN事件是TRUE或已经发生过,那么就不要将它视为有效的按键等等。

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;
             }

阅读这篇文章:http://www.mpgh.net/forum/showthread.php?t=120656