Introducing the hidg0 gem
require 'hidg0'
g = HidG0.new()
sleep 3
g.keypress :a
In order to run the above script follow the Using a Raspberry Pi Zero W as a USB Keyboard instructions, install Ruby on the Pi and then gem install hidg0
.
Then on the host machine open a blank text editor window, and then SSH into the Pi and run the above script. Observe the letter a appears in the text editor window.
Resources
- hidg0 https://rubygems.org/gems/hidg0
- Using a Raspberry Pi Zero W as a USB Keyboard http://www.jamesrobertson.eu/blog/2019/mar/13/using-a-raspberry-pi-zero-w-as-a-usb-keyboard.html
raspberrypi pizero zero pi hid keyboard usb virtual keypress sendkeys