How to use the Pi Cap as a USB keyboard

Learn how to use the Pi Cap as a USB keyboard

The Pi Cap is able to simulate keyboard strokes for each of its 12 electrodes. In this tutorial, we are going to show you how to run the code, how to edit it and more. You are going to need to attach a screen to the Pi as the keyboard strokes are going to be simulated on the attached screen. You can still SSH into the Pi to run the code. Also, we recommend having a look at our Terminal tutorial if you have never used the terminal application on your Pi before.

Step 1 Set up the Pi Cap

If you haven’t set up your Pi Cap then make sure to complete one of our set up tutorials first:

Setting up your Pi Cap on the Raspberry Pi 1, 2 or 3

Setting up your Pi Cap on the Raspberry Pi Zero

Step 2 Connect peripherals

For this tutorial, you need to connect a screen and a mouse to the Pi. The keyboard strokes are going to appear on the screen and the mouse is necessary to open a text editor.

Step 3 Run the code

In order to run the code, open your terminal window. This can either be via SSH or the terminal on your Pi. Then enter “PiCapExamples/Python/picap-keyboard-py/run” and hit enter to run the code. If you now open a text editor on your Raspberry Pi with the mouse, you can touch electrodes 5 to 9 to type “HELLO”.

Step 4 Modify the code

If you want to want to change which keys are pressed with which electrodes, then open the code with “nano PiCapExamples/Python/picap-keyboard-py/”. Between line 42 and 53, you can see which electrodes correspond to which key. Here you can change the keyboard stroke to your choice.

Step 5 Further steps

With the HID keyboard simulation, you can now play games and use the electrodes to press the arrow keys!

We’d love to see your creations, so feel free to send us your images and videos either at or via Twitter or Instagram.

At the time of writing, we don’t have the keyboard simulation code written for Node or C++. Let us know at if you require the code written in C++ and Node.

Have you seen these related resources?