从 CircuitPython 检测主机上按下的修改键

发布于 2025-01-10 17:19:37 字数 188 浏览 0 评论 0原文

我有一个运行 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

心头的小情儿 2025-01-17 17:19:37

我认为如果不在主机端安装一些东西来检测 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文