node-global-listener
A lightweight and efficient Node.js package for capturing global keyboard and mouse events, supporting key presses, mouse movements, input simulation, and background operation. 🚀
Installation
npm install node-global-listener
Compatibility Table:
| Windows | True | Win10,Win11 |
| Mac | Coming Soon | Null |
| Linux | Coming Soon | Null |
Features
- ✅ Keyboard Events: Detect and record key presses, releases, and combinations.
- ✅ Mouse Events: Track mouse position, clicks, and button presses.
- ✅ Input Simulation: Read and write keyboard inputs programmatically.
- ✅ Background Operation: Works seamlessly without interfering with other applications.
Ideal for automation, keylogging (ethical use), and input monitoring. 🚀
Importing the Module
import { KeyboardHandler, KeyEventReader } from "node-global-listener";
Start Listening to Keyboard Events
KeyEventReader
const keyEvent = new KeyEventReader();
keyEvent.on("keyDown", (keyData) => {
console.log(keyData);
});
keyEvent.on("keyUp", (keyData) => {
console.log(keyData);
});
Start Listening to Press (Writing) Keys
KeyboardHandler
const Keys = new KeyboardHandler();
Keys.KeyPress("A");
Keys.KeyDown("b");
Keys.KeyUp("B");
API
KeyEventReader
Class for listening to global keyboard events.
Methods:
on(event: "keyDown" | "keyUp" | "keyPress" , callback: (keyData: KeyData) => void): void - Listens for key press events.
- Future methods will include mouse tracking and advanced key functionalities.
KeyData Structure:
interface KeyData {
KeyCode: number;
KeyUp?: boolean;
KeyDown?: boolean;
Shift: boolean;
CapsLock: boolean;
Control: boolean;
key: string;
}
KeyEventReader
Class for listening to global keyboard events.
Methods:
Keys.KeyPress(KeyName,TIME); // Default TIME 80ms
Keys.KeyDown(KeyName);
Keys.KeyUp(KeyName);
Parameters
- KeyName check for all keys referance. for example "A","B","F1","Delete"...
Development
To contribute to the development of this package:
- Fork the repository.
- Clone your fork:
git clone https://github.com/avinashtare/node-global-listener.git
- Navigate to the project directory:
cd node-global-listener
- Install dependencies:
npm install
- Create a new branch:
git checkout -b feature/your-feature-name
- Make your changes and commit:
git commit -m 'Add new feature'
- Push to your branch:
git push origin feature/your-feature-name
License
This project is licensed under the MIT License. See the LICENSE file for details.
Contact
For questions or contributions, contact: avinashtare.work@gmail.com
Author
卐 🕉 Avinash Tare 🕉 卐