- GetAsyncKeyState function checks whether key is up or down
- and sets the 15th bit of return value as signed short
- then this signed short extends to int in comparison if block
- if key is down 15th bit will be set thus result will be a negative
- comparison also can be done
GetAsyncKeyState(vKey) < 0
-
0x8000(Bit 15 - Most Significant Bit): Indicates whether the key is currently DOWN. -
0x0001(Bit 0): Indicates whether the key was pressed after the previous call. -
By performing a bitwise AND operation (
GetAsyncKeyState(VK_SPACE) & 0x8000), we effectively isolate the MSB to determine the instant physical state of the key regardless of window focus.