1

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.

1
  • 1
    You can detect whether the computer's Caps Lock or Num Lock features are turned on, but I suppose that is not what you are talking about. Commented Mar 1, 2022 at 18:51

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

1 Comment

I see you found my answer to another question! Yeah, I'll probably end up using a button wired to the pico.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.