🚀 Big News:Socket Has Acquired Secure Annex.Learn More
Socket
Book a DemoSign in
Socket

node-global-listener

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

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.

latest
npmnpm
Version
2.1.1
Version published
Maintainers
1
Created
Source

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:

PlatformCompatible?Tested
WindowsTrueWin10,Win11
MacComing SoonNull
LinuxComing SoonNull

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 up

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; // 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 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 🕉 卐

Keywords

keyboard

FAQs

Package last updated on 23 Apr 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts