我需要一个能够获取键盘扫描码的软件

要能获取按键的16进制扫描码。.exe .py .c 皆可
2025-03-10 18:37:39
推荐回答(2个)
回答1:

下面这个是我遇到问题时找到的答案,#1楼的回答十分有用。

并非所有扫描码都能通过这种方式获取,不能获得的那些如果是标准键盘的功能按键可以查表。

否则请搜索KeyCode转ScanCode,大概思路是通过简单方法获得KeyCode,然后在驱动文件中去找定义。因为我没试,所以就不多说了。

获取键盘扫描码

仅供参考

//The _getch function reads a single character from the console without echoing.
//Function can not be used to read CTRL+Break.
//When reading a function key or an arrow key,
//_getch must be called twice; the first call returns 0 or 0xE0,
//and the second call returns the actual key code.
#include 
#include 
void main() {
    unsigned short k;

    while (1) {
        Sleep(100);
        k=getch();
        if (27==k) break;//按Esc键退出
        if (0==k||0xe0==k) k|=getch()<<8;//非字符键
        cprintf("%04x pressed.\r\n",k);
    }
}

回答2:

你在网页里面做一个输入框不行吗?设置成自动获取焦点。微信它也不是用扫码枪啊