Skip to main content

HID python library for emulating mouse and keyboard on PI.

Setup

  1. Install apt dependencies
sudo apt-get update
sudo apt-get install -y git python3-pip python3-venv
  1. install usb gadget module

  2. Create virtual environment

python3 -m venv ~/venv
source ~/venv/bin/activate
  1. Install zero-hid with pip
pip3 install zero-hid
  1. Reboot if not already!

Usage

Note: You should connect the data usb port (left one) to the raspberry, and NOT the power port

  • Control mouse
from zero_hid import Mouse
m = Mouse()
for i in range(5):
    m.move(10, 10)
  • Control keyboard
from zero_hid import Keyboard

k = Keyboard()
k.type('Hello world!')

Features

  • Relative / Absolute mouse movements
  • Left / Right / Middle click
  • Scrolling
  • Typing
  • Hot keys
  • Drag and Drop
  • LEDs status
  • Easy to setup
  • Comprehensive Testing

Examples

see examples

Tests

Raspberry Pi Model Raspbian Version Kernel Version Date of Testing
Raspberry Pi 4 Raspbian 12 (bookworm) 6.6.31 04/08/2024
Raspberry Pi 4 Raspbian 12 6.1 01/01/2023
Raspberry Pi Zero Raspbian 5.10 - 01/01/2023

Gotchas


Absolute mouse used only for positioning - use relative mouse for clicking, etc. See examples.

Metadata

Release files for zero-hid 1.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for zero-hid 1.0.2
File Size Uploaded
zero_hid-1.0.2.tar.gz 28.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for zero-hid 1.0.2
File Interpreter ABI Platform
zero_hid-1.0.2-py3-none-any.whl Python 3 none any Details

Total release size: 64.7 kB

Release files / zero_hid-1.0.2.tar.gz

Download URL zero_hid-1.0.2.tar.gz
Size 28.5 kB
Tags Source
SHA-256 checksum
How to use checksums
18929b87d111a227466c7e49d898c8076d5ae82c6d7720291996f9e5b3c199b7
BLAKE2b-256 checksum
How to use checksums
5b8f4b007fa4a99792b20e0435f69161a1ccd3410b00946c472f3565798a1b18
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.5.29

Release files / zero_hid-1.0.2-py3-none-any.whl

Download URL zero_hid-1.0.2-py3-none-any.whl
Size 36.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fcb4e205b1f1b943aa961efd1d5ee0de46ee253a2d9cd49d578d59a231866e66
BLAKE2b-256 checksum
How to use checksums
773be41821bdfc5eb8293581c2b5749134f33af740110c6a813ca3cce629d5c5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.5.29

Release history Release notifications | RSS feed

This release

1.0.2 This release

2 release files

1.0.1

2 release files

1.0.0

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page