UNPKG

global-input-tracker

Version:

Cross-platform global mouse and keyboard event tracker for Node.js, built with Rust and powered by napi-rs. Detect system-wide key presses and mouse movements in real time.

83 lines (62 loc) โ€ข 2.59 kB
# `global-input-tracker` > Cross-platform global mouse and keyboard event tracker for Node.js using Rust and napi-rs. [![npm](https://img.shields.io/npm/v/global-input-tracker)](https://www.npmjs.com/package/global-input-tracker) [![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE) --- ## โœจ Features - ๐Ÿ” Real-time global keyboard & mouse event tracking - โšก Built in Rust for speed and low overhead - ๐Ÿ”Œ Native Node.js addon via [`napi-rs`](https://napi.rs/) - ๐Ÿ’ป Supports Windows, macOS, Linux (X11) --- ## ๐Ÿš€ Installation ```bash npm install global-input-tracker ``` ```bash yarn add global-input-tracker ``` ## Support matrix ### Operating Systems | | node14 | node16 | node18 | | ---------------- | ------ | ------ | ------ | | Windows x64 | โœ— | โœ— | โœ— | | Windows x32 | โœ— | โœ— | โœ— | | Windows arm64 | โœ— | โœ— | โœ— | | macOS x64 | โœ“ | โœ“ | โœ“ | | macOS arm64 | โœ— | โœ— | โœ— | | Linux x64 gnu | โœ“ | โœ“ | โœ“ | | Linux x64 musl | โœ“ | โœ“ | โœ“ | | Linux arm gnu | โœ— | โœ— | โœ— | | Linux arm64 gnu | โœ— | โœ— | โœ— | | Linux arm64 musl | โœ— | โœ— | โœ— | | Android arm64 | โœ— | โœ— | โœ— | | Android armv7 | โœ— | โœ— | โœ— | | FreeBSD x64 | โœ“ | โœ“ | โœ“ | ## Ability ### Global Input Tracking - Monitor all keyboard presses and releases across the system - Track mouse movements globally, even outside your app window - Detect mouse button presses and releases ### ๐Ÿ”„ Cross-Platform Support - Works on macOS, Linux (GNU + MUSL), and FreeBSD - Node.js runtime support: Node 14+, 16+, 18+ ### ๐Ÿ”Œ Efficient Native Performance - Powered by Rust and rdev for low-latency input detection - Uses napi-rs for safe and efficient FFI to Node.js ### ๐Ÿงฉ Structured Event Data - Returns rich InputEvent objects including: - event_type (e.g., KeyDown, MouseMove) - payload (e.g., KeyA, LeftButton) - x, y mouse coordinates (when applicable) ### ๐Ÿ‘‚ Background Event Listener - Runs in a background thread without blocking the main Node.js event loop - Designed for real-time, asynchronous input handling ### ๐Ÿ›  TypeScript Friendly - Auto-generated TypeScript types - Easy to use in both JavaScript and TypeScript environments ## ๐Ÿงช Run Example To test the module locally with an example script: ``` node examples/main.mjs ```