A1VBCode Forums

How to detect keypress instantly using API with C++?


http://www.a1vbcode.com/vbforums/Topic24373.aspx

By kazamamakoto - 3/10/2008

Yo all. Trying to detect KeyPress instantly using the GetAsyncKeyState API for C++ but im only able to get certain keys (with the MSDN tutorial at least). Should I use another API or is GetAsyncKeyState capable of detecting all keys being pressed? Thanks
By Anasazi - 5/11/2008

Trying to write a keylogger are we? ;-]

Anyway though, yes. Using getasynckeystate is a good way but not the best.

You will find it quite annoying to use GetAs... for logging keystrokes, since it requires a hughe(or small) switch statement and a sleep command in order to avoid 100% cpu usage which will fail on loggin every keystroke if the user is a really fast typer.

I would recommend a keyboard hook though, but if you feel you deserve an example I can write a GetAsync... for you.