Using GetAsyncKeyState() to accurately get keystrokes.

Hello. I wanted to write a program that could get keys pressed even when the program wasn't in focus. I tried using _getch(), which only partialy did what I wanted, as it worked provided the program was in focus. I thought of using GetAsyncKeyState() which both gets if a key is pressed and works when the program is out of focus. But to accurately build up a string of what the user is typing I want my keystroke recording function to consider how the user has configured their keyboard in relation to keys being repeated depending on how long they are pressed down. For example, if I where to press the 'h' key for half a second, on my configuration I would get a single 'h' character appended to my string when using _getch(). But when using GetAsyncKeyState(), I get multiple 'h' characters added to my string which are not actually being typed. I would be very grateful is someone could show me how to use GetAsyncKeyState() in the mannor I have described, or if it is more efficent, another function I could use to achive my goal. Thankyou.
Hey there, i was looking for the values the GetAsyncKeyState() uses for control keys so i can receive them properly into my program when i came across your question.

Is it correct that you're wanting your program to know when a key has been
released before accepting another key-press?

If so then i can help you with that 'cos I've set this up in my program already (expecting that CPU speed will shoot through program at tremendous speeds and recognize the key pressed at thousands of times per second), However if you press and release a key with a key held down before it, the program cannot see this. (although this is unlikely apart from buttons such as <SHIFT> which is why i want to eliminate them properly)
Topic archived. No new replies allowed.