GetAsyncKeyState and some problems?
Why do i get more than 1 (a few hundred) key hit on a single press while using 开发者_运维问答GetAsyncKeyState. It prints a hundred of a same key while i just pressed it once. Thanks,
GetAsyncKeyState
tells you the state of the keyboard, whether a key is down/up, not whether it has been pressed since last call. If you call it in a loop, you will get "key is down" for as long as you keep the key down - and that loop executes a lot faster than you can move your fingers.
If you want keyboard events handle WM_KEYDOWN
and WM_KEYUP
.
If you want a global hotkey, use RegisterHotKey
精彩评论