有没有办法以编程方式检查是否连接了 Mac 或 PC 键盘?
有没有办法以编程方式可靠地检查连接到计算机的键盘是带有 Command (⌘) 和选项键的 Mac 键盘,还是带有 Windows、Alt 和 Menu 键的 PC 键盘?为简单起见,假设计算机上仅连接一个键盘。如果有的话,独立于操作系统的解决方案将是最好的,但如果您必须采用操作系统,请采用 Windows 7。
Is there a way to reliably check programmatically if the keyboard attached to a computer is a Mac keyboard with Command (⌘) and option keys, or a PC keyboard with Windows, Alt, and Menu keys? For simplicity's sake assume that there is only one keyboard attached to the computer. An operating system independent solution would be best if there is one, but if you have to assume an OS, assume Windows 7.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
枚举连接的 USB 设备并查找键盘。如果您找到一个,并且它的供应商 ID 为 0x05AC(Apple Inc),那么它肯定是 Apple 键盘。如果供应商是其他供应商,或者如果您没有找到任何 USB 键盘(例如,键盘可能通过 PS2 连接),那么它可能不是 Apple 键盘。
Enumerate the attached USB devices and look for a keyboard. If you find one, and it's got a vendor id of 0x05AC (Apple Inc), then it's definitely an Apple keyboard. If the vendor is something else, or if you don't find any USB keyboards (e.g, the keyboard is probably hooked up via PS2), then it's probably not an Apple keyboard.