GetAsyncKeyState -- Case question

hi, im doing an app that need to determine the keystroke of the user and the case. but.... it is not working.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include <iostream>
#include <windows.h>
using namespace std;
int main()
{
      while (1)
      {     Sleep(100);
            if(GetAsyncKeyState(0x41)){
            	cout << "A\n";
            }
            else if(GetAsyncKeyState(0x61)){
            	cout << "a\n";
            }
            else{
            	cout << "null\n";
            }
      }

      return 0;
}


whenever i press "A" on the keyboard, no matter if the letter typed is "A" or "a", the program will always return "A". what should i do to fix this?

thanks.
Last edited on
GetAsyncKeyState really reports which key on the key board is pressed.
The A key has the value 65 decimal 41 hex - which happens to be ascii for capital A.

Key 61 hex is the 1 key on the numberic keypad - not lower case a.
Topic archived. No new replies allowed.