Skip to content

Raspberry Pi Zero W appears as wired keyboard when connected to computer

Notifications You must be signed in to change notification settings

buoyantbeaver/pi-as-keyboard

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

37 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pi-as-keyboard

Tested on Banana Pi BPI-M2 ZERO running the 2022-09-07 Armbian jammy_edge_5.19.6_xfce_desktop image from the official wiki page.

Installation

  1. Start with a clean install of Raspberry Pi OS or Ubuntu with internet/wifi configured.
  2. SSH into the pi and run the following:
curl -sSL https://raw.githubusercontent.com/alxvngn/pi-as-keyboard/master/install.sh | sudo bash -
  1. Once the installation is finished, shutdown the pi, remove its power supply and use a regular microUSB to USB cable (non-OTG) to plug it into the USB connector marked USB on the board (the one next to the HDMI connector). Plug other end to a computer/mac.

The computer/mac will recognize the pi as a generic HID USB Keyboard. Open a text editor on the target computer/mac and test it.

Instruction

Use another computer and ssh into the pi then run:

echo 'left-shift h' | ~/pi-as-keyboard/keeb /dev/hidg0 keyboard
echo 'i' | ~/pi-as-keyboard/keeb /dev/hidg0 keyboard

Or conveniently:

~/pi-as-keyboard/sendkeys left-shift h
~/pi-as-keyboard/sendkeys i

Success! Should see Hi in notepad Take a look at https://github.com/alxvngn/pi-as-keyboard/blob/master/keeb.c#L20 for available keys.

About

Raspberry Pi Zero W appears as wired keyboard when connected to computer

Topics

Resources

Stars

Watchers

Forks

Languages

  • C 93.7%
  • Shell 6.3%