Computer Lock Button Using CircuitPython

What happened at the Capitol on January 6, 2021 will go down as a dark day in American history. There are many potential cybersecurity issues related to this incident. Images from inside the Capitol showed at least one computer left unlocked. “We can use this as a learning moment”, as Rachel Tobac, an information security leader, points out in her twitter thread below.

I thought a quick exercise in using this as a learning moment would be to modify my recent Zoom/Microsoft Teams mute button project to create a simple and easy to use computer lock button.

Parts

Wiring

The fritzing schematic is below. Please note that the button I used didn’t have a NC connector, but I couldn’t find a similar part in the fritzing library.

Code

I simplified my code from the Zoom/Microsoft Teams mute button project for this to make it easy and simple to use. The specific kbd.send line will need to be uncommented depending on the operating system. Save the below code as code.py to your QT Py CIRCUITPY drive.