问题描述
是否仅使用扫描码就可以获取键盘按键的状态(按下或按下)?我在win32中找不到任何函数.有谁知道实现此目的的任何方法吗?
Is there anyway to get the state of a keyboard key (is it down or up) using just a scancode? I can't find any function in win32 for this. Anyone know any way to achieve this?
p.s.我需要键盘的实际状态,而不是从Windows消息(如GetKeyState返回)得出的状态.
p.s. I need the actual state of the keyboard not the state derived from windows messages like GetKeyState returns.
推荐答案
您将必须使用 MapVirtualKey
函数,使用MAPVK_VSC_TO_VK
作为模式,并将输出传递到GetKeyState
或 GetKeyboardState
,因为没有一个WinAPI键功能直接使用扫描代码
You'll have to use the MapVirtualKey
function, using MAPVK_VSC_TO_VK
as the mode, and pass the output to GetKeyState
or GetKeyboardState
, as none of the WinAPI key functions directly use scan codes
这篇关于如何通过扫描码(不是虚拟键码)获取键状态?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!