3. Implementation/Windows API

GetAsyncKeyState 사용법

SSKK 2011. 8. 16. 23:13
키의 다운 여부를 체크하기 위한 GetAsyncKeyState 함수가 있습니다. 이에 대한 사용법은 다음과 같습니다.

if (GetAsyncKeyState(VK_SHIFT) & 0x8000)
{
   // The key is currently down
}


unsigned char KeyStates[256];
GetKeyboardState(KeyStates);

for (int i = 0; i < 256; i++)
{
      if (KeyStates[i] & 0x8000)
      {
            // The keyboard key that 'i' represents is currently held down.
      }
}


출처: http://cboard.cprogramming.com/cplusplus-programming/112970-getasynckeystate-key-pressed.html