开发者

C/C++ GetAsyncKeyState() Key combination

开发者 https://www.devze.com 2022-12-29 13:50 出处:网络
I understand how to use this function with one key, but how can I use it with 开发者_JAVA百科two keypresses?

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消