Xiao RP2040 Program Rocker Switch CirctuitPython

Hello - I’m new to microcontrollers and circuitpython, basically all of this. I’ve figured out how to program my Xiao RP2040 to continuously send a keycap command to my computer when plugged in. However, it currently does it the moment it’s plugged in until I unplug it. I’d like to program for it to only initiate when I flip a rocker switch, and then cease when I flip it back. Can anyone point me in the right direction for what the circuitpython should look like and what pins I would need to solder to?

Thanks!