C/C++ GetAsyncKeyState() Key combination
I understand how to use this function with one key, but how can I use it with 开发者_JAVA百科two keypresses?
Like: GetAsyncKeyStat(VK_LBUTTON && VK_RBUTTON);
You would have to call GetAsyncKeyState
twice.
//"And" the returns of GetAsyncKeyState
//Then "and" the result with 0x8000 to get whether or not the Most Significant Bit is set
bool bBothPressed = GetAsyncKeyState(VK_LBUTTON) & GetAsyncKeyState(VK_RBUTTON) & 0x8000;
Generally the best answer if you want to query multiple keys is to use GetKeyboardState that returns the state of every Virtual key in an array which you can process directly and efficiently.
精彩评论