从 CircuitPython 检测主机上按下的修改键
我有一个运行 CircuitPython 的 Raspberry Pi Pico。当开发板通过 USB 连接到主机时,该开发板上的 python 代码是否可以检测主机键盘上是否按下了修改键?
我对 USB 协议的了解有限,但感觉 Pico 需要监听通过 USB 显式发送的数据。我不认为按键会以这种方式发送。
我很高兴被证明是错误的。
I have a Raspberry Pi Pico running CircuitPython. Is it possible for the python code on this board to detect if a modifier key is pressed on the host computer's keyboard when the board is connected to the host over USB?
My knowledge of USB protocols is limited but it feels like the Pico would need to be listening to data explicitly sent over USB. I don't think that key presses would be sent that way.
I'd be happy to be proven wrong.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为如果不在主机端安装一些东西来检测 Pico 何时连接、检查按下了哪些键并相应地与 Pico 通信,您就无法做到这一点。
如果主机是 Windows,则快速搜索会找到使用 Windows Management Instrumentation 的此当 USB 设备发生变化时运行 Python 代码。
或者,您可以将硬件按钮连接到 Pico,并在 Pico 检测到它已连接到 USB 主机时检查该按钮 - 您似乎已经弄清楚了这一点。
I don't think you can do this without installing something on the host computer side to detect when the Pico was connected, check what keys were pressed and communicate with the Pico accordingly.
If the host computer is Windows then a quick search finds this which uses Windows Management Instrumentation to run Python code when a USB device changes.
Alternatively, you could attach a hardware button to the Pico and check that button when the Pico detects that it has been connected to a USB host - you appear to have already figured this out.