开发者

GetAsyncKeyState and some problems?

开发者 https://www.devze.com 2023-02-16 19:39 出处:网络
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.

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

0

精彩评论

暂无评论...
验证码 换一张
取 消