Pico as USB keyboard

I want to set up the pico as a defacto USB keyboard. I have to use 3rd party software that asks for my password about 50 times a day (bad software), so all I need is to send a set of characters down the USB line on keypress. I’ve managed to do this with CircuitPython, and it works fine, but I would like to wire in the capacitative touch sensor PiicoDev CAP1203, for which it seems there are no CircuitPython drivers?

On the other hand, using MicroPython (for which there are drivers) via the ‘USBDevice’
(class USBDevice – USB Device driver — MicroPython latest documentation) I’m afraid is too low-level for me to spend the time working it out.

So are there CircuitPython drivers for the touch sensors, or higher level modules for USBDevice??

Thanks for any ideas!

1 Like

I think I would solve this by writing a wrapper for the Piicodev cap1203 in circuit python.
How does that feel to you? :slight_smile:

While you may have some very specific needs, from your description this is exactly where the " USB Rubber Ducky" started from https://shop.hak5.org/products/usb-rubber-ducky
It has a full scripting so you can do things like
send ctrl-alt-del
wait x ms
send “username”
send tab
send password
send enter
wait 500ms
send windows key
etc.

If you go for its bigger brother it has storage as well so you can copy files to/from the device.

Also the ESP32 S3 can do HID keyboard and with an adapter you can connet to the USB-A port on a PC


that is my test project which also had a web page where I could send “commands” for it to type onto the current PC remotely.

1 Like

Hi @David197028

My solution to this problem was to use the Sparkfun CAP1203 library for C++.

Below is a code example that you can tinker with to output what you what.

#include <Wire.h>
#include <Keyboard.h> 
#include "SparkFun_CAP1203.h" //  http://librarymanager/All#SparkFun_CAP1203

CAP1203 sensor; // Initialize sensor

void setup()
{
  Wire.setSDA(8);  // Set SDA to pin 8
  Wire.setSCL(9);  // Set SCL to pin 9
  Wire.begin();       // Join I2C bus
}

void loop()
{
  if (sensor.isLeftTouched() == true)
  {
    //Keyboard.print("rainbow:wave2: Buying GF 10K");                            
    delay(100);
  }

  if (sensor.isMiddleTouched() == true)
  {                    
    //Keyboard.press(KEY_LEFT_CTRL);
    //Keyboard.press(KEY_LEFT_ALT); 
    //Keyboard.press(KEY_ESC);
    //Keyboard.releaseAll();
    delay(100);
  }

  if (sensor.isRightTouched() == true)
  {
    //Keyboard.press(KEY_LEFT_CTRL);
    //Keyboard.print("a");
    //Keyboard.press(KEY_LEFT_CTRL);
    //Keyboard.print("c");
    //Keyboard.releaseAll();
    delay(100);
  }
}

Thanks for all the useful suggestions. In the end, given that time resources are a bit limited for a simple project like this, I thought discretion vs valour etc, and just went with the TTP223 touch sensor which has good circuitpython support! Now all working fine!

1 Like

Hey @David197028

Great to hear that you got it all working in the end!

1 Like