GetAsyncKeyState 还有一些问题?
为什么在使用 GetAsyncKeyState 时,单次按下时会出现超过 1 个(几百个)按键的情况。当我只按一次时,它会打印一百个相同的键。 谢谢,
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,
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
GetAsyncKeyState
告诉您键盘的状态,某个键是否按下/向上,而不是自上次调用以来是否已按下。如果你在循环中调用它,只要你按住键,你就会得到“key is down”的信息 - 并且该循环的执行速度比你移动手指的速度要快得多。如果您想要键盘事件处理
WM_KEYDOWN
和WM_KEYUP
。如果您想要全局热键,请使用
RegisterHotKey
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
andWM_KEYUP
.If you want a global hotkey, use
RegisterHotKey