1.0.3 • Published 3 years ago

atrijs v1.0.3

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

ATRI.js

A high-performance keyboard and mouse monitor for Node.js (Windows only)

Installation

Install by using npm:

$ npm install --save atrijs

Install by using yarn:

$ yarn add atrijs

Getting started

const Atri = require('atrijs');

const atri = new Atri();

atri.on('keydown', (/**@type {ATRI.EventData} */ event) => {
  console.log(`Key "${event.keyName}" pressed!`)
});

atri.on('keyup', (/**@type {ATRI.EventData} */ event) => {
  console.log(`Key "${event.keyName}" released!`)
});

Available Events

  • keydown
  • keyup
  • mousedown
  • mouseup
  • mousemove
  • mousewheel

Structure of event callback

interface EventData {
  // Type of current event
  type: string

  // Only set in `keydown`, `keyup`, `mousedown`, `mouseup` events.
  keyCode: number

  // Name of key
  keyName: string

  // Is `Alt` key pressed
  alt: boolean

  // Is `Ctrl` key pressed
  ctrl: boolean

  // Is `Shift` key pressed
  shift: boolean

  // Is `Win` key pressed
  win: boolean

  // Only set in `mousewheel` event
  wheel: number

  // Current position X of cursor
  cursorX: number

  // Current position Y of cursor
  cursorY: number

  // Timestamp of current event
  timestamp: number
}

Reference

Virtual-Key Codes