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.
91 lines (62 loc) โข 2.59 kB
Markdown
# `global-input-tracker`
> Cross-platform global mouse and keyboard event tracker for Node.js using Rust and napi-rs.
[](https://www.npmjs.com/package/global-input-tracker)
[](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
```