更改 USB 键盘的击键
每次在常规键盘上按下一个键时,都会将数字“键代码”发送到计算机,例如。 32或51代表特定的按键。
与我用来输入这篇文章的默认键盘无关,我希望能够通过 USB 插入键盘,并将其键码全部向上移动一些常量 C。
因此,当按此键盘上的“a”键时侧键盘时,计算机不会接收“a”的键码,而是接收计算机没有计划响应的更高数字。
这些超出常规范围的击键将控制我的程序,该程序知道它们是什么并且会监听它们。
硬件或软件解决方案适合我。也许有为此目的出售的特殊键盘,或者也许一些与软件相关的修改可以让任何常规键盘实现这一点——我不知道。至关重要的是,键码转换仅适用于我的侧面键盘,而不适用于我用于常规操作的默认键盘。
我在 Windows 上。
Every time a key is pressed on a regular keyboard, a numeric 'key code' is sent to the computer, eg. 32 or 51 which represent specific keys.
Unrelated to my default keyboard which I am using to type this post, I want to be able to plug in a keyboard via USB and have its key codes all shifted up by some constant C.
Thus, when pressing the 'a' key on this side keyboard, the computer would not receive the keycode for 'a', but rather some higher number which the computer does not have a planned response to.
These out-of-conventional-range keystrokes will control a program of mine which knows what they are and will be listening for them.
Hardware or software solution would work for me. Perhaps there are special keyboards sold for this end, or maybe some software-related modification could let this be accomplished for any regular keyboard-- I have no idea. What is crucial is that the keycode shift applies only for my side keyboard and not my default keyboard which I use for regular stuff.
I'm on Windows.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我认为你对自己的限制远远超过了必要的程度。
对于初学者来说,您对 USB 键盘的描述已经简化了很多。情况比这要复杂一些。例如,您实际上获得了按键/按键序列。 (也称为“通断”)。
接下来的事情是您对操作系统对键盘的处理进行假设。如果第二个键盘声称它是 USB 键盘,则它将由 USB 键盘的操作系统驱动程序处理。这不会期望改变值。例如,在 Microsoft Windows 上,记录了以下行为:
接下来,操作系统将假设额外的键盘将提供额外的按键,并直接处理它。例如,有适用于笔记本电脑的数字 USB 键盘,Windows 只是将它们视为额外的 0-9+-/*= 键。它并不关心它们位于单独的硬件上。基本上,我认为第二个键盘想法不会成功。
现在 USB 通常将键盘视为更通用类的特例,这更加灵活: HID = 人类输入设备。 。例如,USB 操纵杆也是人类输入设备,典型的操作系统不会尝试解释操纵杆按钮。游戏应该直接处理它们,您的应用程序也可以。
I think you are restricting yourself far more than necessary.
For starters, your description of USB keyboards is simplified a lot. The situation is a bit more complex than that. For instance, you actually get key-down/key-up sequences. (Also known as make and break).
The next thing is that you're making assumptions about the handling of the keyboard by the OS. If the second keyboard claims it's an USB keyboard, it will be handled by the OS driver for USB keyboards. That will not expect shifted values. For instance, on Microsoft Windows, the following behavior is documented:
Next, an OS will assume that an extra keybaord will provide extra keys, and handle it directly. For instance, there are numeric USB keyboards available for laptops, and Windows just treats them as extra 0-9+-/*= keys. It doesn't care that they're on separate hardware. Basically, I don't think this second keayboard idea will fly.
Now USB usually treats keyboard as a special case of a more generic class, which is more flexible: HID = Human Input Devices. . For instance, USB joysticks are also Human Input Devices, and a typical OS doesn't try to interpret joystick buttons. Games are expected to handle them directly, and so could your app.
嗯,听起来您需要更多的硬件解决方案而不是编程解决方案。试试这个 http://www.instructables.com/id/Hacking-a -USB-键盘/
Well it sounds like you'll need more of a hardware solution than a programming solution. Try this http://www.instructables.com/id/Hacking-a-USB-Keyboard/