node-global-listener
v2.1.1
Published
A lightweight and efficient Node.js package for capturing global keyboard and mouse events, supporting key presses, mouse movements, input simulation, and background operation.
Maintainers
Readme
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-listenerCompatibility Table:
| Platform | Compatible? | Tested | | -------- | ----------- | ----------- | | 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();
// Listen for keyDown events
keyEvent.on("keyDown", (keyData) => {
console.log(keyData);
});
// Listen for keyUp events
keyEvent.on("keyUp", (keyData) => {
console.log(keyData);
});Start Listening to Press (Writing) Keys
KeyboardHandler
const Keys = new KeyboardHandler();
Keys.KeyPress("A"); // key press
Keys.KeyDown("b"); // key down
Keys.KeyUp("B"); // key upAPI
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; // Key code
KeyUp?: boolean; // Key pressed
KeyDown?: boolean; // Key relsesed
Shift: boolean;
CapsLock: boolean;
Control: boolean;
key: string;
}KeyEventReader
Class for listening to global keyboard events.
Methods:
Keys.KeyPress(KeyName,TIME);// Default TIME 80msKeys.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: [email protected]
Author
卐 🕉 Avinash Tare 🕉 卐
