UNPKG

node-global-listener

Version:

A lightweight and efficient Node.js package for capturing global keyboard and mouse events, supporting key presses, mouse movements, input simulation, and background operation.

28 lines (22 loc) 728 B
import { KeyEventReader, KeyboardWriter } from "./index"; import { KeyData } from "./lib/windows/keyReader/types"; console.log("** Program Started **"); // *** Key Reader *** const keyEvent = new KeyEventReader(); // Handle Key Down // keyEvent.on("keyDown", (keyData: KeyData) => { // console.log(`KeyDown: `, keyData.key); // }); // Handle Key Up keyEvent.on("keyUp", (keyData: KeyData) => { console.log(`KeyUp: `, keyData.key); }); // Handle Key Press // keyEvent.on("keyPress", (keyData: KeyData) => { // /* */ // console.log(`KeyUp: `, keyData.key); // }); // ***** Keyboard Handler ***** const Keys = new KeyboardWriter(); Keys.press("A"); // key press Keys.down("b"); // key down