Skip to content

Latest commit

ย 

History

History
241 lines (164 loc) ยท 9.53 KB

File metadata and controls

241 lines (164 loc) ยท 9.53 KB

Typing SVG

Python OpenCV MediaPipe NumPy PyAutoGUI Windows License

Star Forks GitHub


โ•”โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•—
โ•‘                                                                      โ•‘
โ•‘   Type at 200 WPM โ€” using only your hands in mid-air.               โ•‘
โ•‘   No physical keyboard. No desk. Just you and the camera.            โ•‘
โ•‘                                              โ€” Tcode-Motion โšก        โ•‘
โ•šโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•

๐Ÿค– About

A high-performance, augmented reality virtual keyboard controlled by AI hand gestures and mouse input. Powered by OpenCV and MediaPipe, it overlays a Ghost HUD keyboard on your screen and tracks your finger movements in real-time โ€” letting you type in any Windows application without ever touching a physical keyboard.

๐ŸŽฏ Point your finger. Tap. It types. That's it. Welcome to spatial computing.


๐Ÿš€ Key Features

โšก Feature ๐Ÿ“– Description
๐Ÿ‘ป Ghost HUD Mode Uses Windows ctypes API โ€” Always on Top + No-Focus. Types into ANY app without stealing window focus
๐ŸŽฏ Precision Strike Typing AI detects a "click" from decisive downward fingertip motion โ€” Binary-State Trigger
โšก 200 WPM Capable Ultra-low latency with 120ms debounce timer + high-speed tracking (alpha=0.92)
โŒจ๏ธ Full HP Layout Function Row (F1-F12), Navigation cluster, full Numpad โ€” complete keyboard
๐Ÿ–๏ธ Dual-Hand Support Independent tracking for all 8 fingers (Index to Pinky) across both hands
๐ŸŽจ Professional HUD UI Semi-transparent Navy-Glass aesthetic with Electric Cyan borders + Orange status indicators
๐Ÿ”€ Hybrid Control Switch between AI Hand Gestures and Mouse Clicks instantly
โฑ๏ธ Dwell Trigger Hold finger over key for 0.6s โ†’ visual progress bar fills โ†’ auto-types

๐Ÿง  Core Logic & Typing Engine

1. ๐ŸŽฏ Precision Strike โ€” Hand Gesture Detection

Uses Depth-Aware Dynamic Thresholding โ€” scales sensitivity to your hand's distance from the camera:

hand_scale = dist(wrist, middle_finger_base)
tap_threshold = hand_scale * 0.08

A keystroke fires if a finger moves downward by more than 8% of the hand's size โ€” works consistently whether your hand is near or far from the camera.

2. โฑ๏ธ Dwell Fallback Trigger

Hold a finger over any key for 0.6 seconds โ†’ a visual progress bar fills inside the key โ†’ keystroke fires automatically. Perfect for accessibility.

3. ๐Ÿ‘ป Ghost Window โ€” ctypes Magic

The HUD window is rendered invisible to the Windows Focus Manager:

Flag Effect
WS_EX_NOACTIVATE Prevents window from stealing foreground focus when clicked
WS_EX_TOPMOST Keeps HUD above all other applications
WS_EX_APPWINDOW Keeps it visible in Taskbar

โŒจ๏ธ Advanced Layout & Controls

๐ŸŽ›๏ธ Function Keys (F1-F12)

Mode Behaviour
Normal Mode Media Controls โ€” Emoji Panel, Brightness, Volume, Mic Mute, Media Prev/Play/Next
Fn-Locked Mode Standard Windows F1-F12 keys

๐Ÿ”ข Dual-Mode Numpad

Mode Behaviour
NumLock ON Standard numeric entry (0-9, . , Enter)
NumLock OFF Navigation Cluster โ€” Home, End, PgUp, PgDn, Arrows, Insert, Delete

๐Ÿ”˜ System Buttons

  • Pwr โ€” Top right. Instantly closes the Virtual Keyboard
  • Shift / Ctrl / Alt โ€” Sticky toggles. Click once to lock, click again to release

๐Ÿ› ๏ธ Tech Stack

Python OpenCV MediaPipe NumPy PyAutoGUI ctypes

Library Purpose
OpenCV Camera feed capture, frame rendering, AR overlay
MediaPipe Real-time AI hand landmark detection (21 points per hand)
NumPy Geometry math โ€” distance calculations, thresholding
PyAutoGUI Injects real keystrokes into active Windows applications
ctypes Windows API โ€” Ghost HUD window flags

๐Ÿ“ฆ Installation

Prerequisites

  • Windows 10 or 11
  • Python 3.10+
  • Standard webcam

Setup

# 1. Clone the repository
git clone https://github.com/Tcode-Motion/virtual-keyboard.git
cd virtual-keyboard

# 2. Install dependencies
pip install opencv-python mediapipe pyautogui numpy

# 3. Run the application
python virtual_keyboard_v2_main.py

๐ŸŽฎ How to Use

Step 1 โ†’ Run the script โ†’ Ghost HUD keyboard appears on screen
Step 2 โ†’ Position hands in front of webcam
         โ†’ Glowing MediaPipe landmarks overlay your fingers
Step 3 โ†’ Use a quick "pecking" tap motion toward camera to type
         OR simply click any key with your mouse
Step 4 โ†’ Click into any app (Notepad, Chrome, Discord, Games)
         โ†’ Virtual Keyboard injects text directly โ€” globally
Step 5 โ†’ Exit: click Pwr button (top right) or press Q

๐Ÿ“ Project Structure

virtual-keyboard/
โ”œโ”€โ”€ virtual_keyboard_v2_main.py   # Main entry point โ€” run this
โ””โ”€โ”€ README.md

๐Ÿ“œ System Requirements

Requirement Spec
OS Windows 10 / 11 (Ghost HUD ctypes required)
Python 3.10 or higher
Hardware Standard webcam
Dependencies opencv-python, mediapipe, pyautogui, numpy

๐Ÿค Contributing

Contributions welcome โ€” especially for:

  • ๐ŸŽฏ Gesture smoothing improvements

  • ๐ŸŽจ HUD aesthetic upgrades

  • ๐Ÿง Linux/macOS port (replacing ctypes with cross-platform alternative)

  • โญ Star the repo if you like it!

  • ๐Ÿ› Open an issue for bugs

  • ๐Ÿ”ง Submit a PR for improvements


๐Ÿ‘จโ€๐Ÿ’ป Author

Tanmoy โ€” Tcode-Motion

GitHub YouTube

"Predict the future by coding it." โšก


๐Ÿ“„ License

This project is licensed under the MIT License.