tags:

views:

675

answers:

2

I understand how to use this function with one key, but how can I use it with two keypresses?

Like: GetAsyncKeyStat(VK_LBUTTON && VK_RBUTTON);

+3  A: 

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;
Igor Zevaka
Elemental
@Elemental: You mean 0x8000?
dalle
indeed I do mean 0x8000 - thanks
Elemental
Yes, my bad, it was meant to be 0x8000.
Igor Zevaka
+2  A: 

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.

Elemental