Minimal prototype using MediaPipe Hands + OpenCV to recognize simple hand gestures and map them to keyboard/mouse controls for people who want to play League of Legends.
This project enables real-time hand gesture control for keyboard and mouse actions using MediaPipe Hands and pynput. The system supports two-hand interactions with distinct roles for the left and right hands.
The left hand controls keyboard shortcuts. Single-finger gestures map to specific keys:
| Gesture (Finger) | Action (Key Press) | Notes |
|---|---|---|
| Index | Q |
Tap when thumb is extended, only one finger extended at a time |
| Middle | W |
Tap when index finger is extended |
| Ring | E |
Tap when middle finger is extended |
| Pinky | R |
Tap when ring finger is extended |
| Other / Fist / Multiple fingers | None | Ignored to prevent accidental triggers |
- The left hand uses a cooldown (
0.25s) between actions to avoid multiple rapid key presses. - Only one finger extended at a time triggers an action; ambiguous gestures are ignored.
The right hand controls the mouse pointer and clicks:
| Gesture / Movement | Action | Notes |
|---|---|---|
| Index finger movement | Moves the cursor | Tracks the index fingertip position frame-to-frame for smooth movement. Adjustable gain and smoothing parameters. |
| Pinch (Index + Thumb) | Left click | Detects pinch distance below threshold (0.05 normalized units). |
| Pinch (Middle + Thumb) | Right click | Detects pinch distance below threshold. |
- Right-hand gestures operate continuously without toggling.
- Mouse movement is smoothed using an exponential filter to reduce jitter.
- Controls are always enabled while
main.pyruns. - Uses normalized MediaPipe coordinates, automatically mapped to screen cursor positions.
- Both hands can operate simultaneously for keyboard and mouse control.
- Visualization HUD shows gesture detection and current status for feedback.
- Python 3.10 or 3.11 recommended
python3 -m venv .venv
source .venv/bin/activate
python -m pip install --upgrade pip
pip install -r requirements.txtpython src/main.py