# @abberdeen/global-mkh

> Global keyboard and mouse events listener for Node.js (Windows only)

Latest version **1.0.11** (published 2023-09-26) · MIT license · 0 weekly downloads

## Install

```sh
npm install @abberdeen/global-mkh
pnpm add @abberdeen/global-mkh
yarn add @abberdeen/global-mkh
bun add @abberdeen/global-mkh
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.11 |
| Published | 2023-09-26 |
| First published | 2023-09-17 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 27.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | yes |
| Author | abberdeen |
| Maintainers | abberdeen |
| Keywords | mouse-hooks, windows, mouse-events, mouse, keyboard, electron, windows-hooks, hooks, global, node |

## Links

- npm: https://www.npmjs.com/package/@abberdeen/global-mkh
- Repository: https://github.com/abberdeen/global-mkh
- Homepage: https://github.com/abberdeen/global-mkh#readme
- Issues: https://github.com/abberdeen/global-mkh/issues
- npm.io page: https://npm.io/package/@abberdeen/global-mkh

## Dependencies (3)

- [bindings](https://npm.io/package/bindings.md) 1.5.0
- [node-gyp](https://npm.io/package/node-gyp.md) 7.1.2
- [node-addon-api](https://npm.io/package/node-addon-api.md) 3.1.0

## Alternatives

- [@opentelemetry/exporter-zipkin](https://npm.io/package/@opentelemetry/exporter-zipkin.md) — 14.8M weekly downloads
- [pusher-js](https://npm.io/package/pusher-js.md) — 2.0M weekly downloads
- [browserify](https://npm.io/package/browserify.md) — 1.7M weekly downloads
- [sqs-consumer](https://npm.io/package/sqs-consumer.md) — 1.7M weekly downloads
- [@sanity/eventsource](https://npm.io/package/@sanity/eventsource.md) — 930.8K weekly downloads

## Recent versions

- 1.0.11 (latest) — 2023-09-26
- 1.0.10 — 2023-09-25
- 1.0.9 — 2023-09-25
- 1.0.8 — 2023-09-25
- 1.0.7 — 2023-09-23
- 1.0.6 — 2023-09-22
- 1.0.5 — 2023-09-22
- 1.0.4 — 2023-09-17
- 1.0.2 — 2023-09-17
- 1.0.1 — 2023-09-17
- 1.0.0 — 2023-09-17

## README

# global-mkh

An event based, Global Keyboard and Mouse listener for Node.js (Windows only). Based off of [xanderfrangos/global-mouse-events](https://github.com/xanderfrangos/global-mouse-events) and [borecjeborec1/lepikEvents](https://github.com/borecjeborec1/lepikEvents).

## Installation

```cmd
npm i @abberdeen/global-mkh
```

## Usage
Import the module and register for the mouse events you'd like to listen to.

### Available event listeners

**`keyup`** / **`keydown`** — *Fires when a keyboard button is pressed / released.*\
Returns:
- **keyName:** Return the pressed single key name.
- **combination**  Return pressed key in the end along with the modifiers if they are (control, shift, and alt), separated by a '+'. 
- **shiftKey** Boolean is pressed Shift key.
- **ctrlKey** Boolean is pressed Control key.
- **altKey** Boolean is pressed Alt key.
- **metaKey** Boolean is pressed Meta (Win) key. 
- **crazyCombination** Available only on key up. String key combinations, ordered by the order they are pressed.

**`mouseup`** / **`mousedown`** — *Fires when a mouse button is pressed / released.*\
Returns:
- **x:** The X position of the mouse, relative to the top left of the primary display.
- **y:** The Y position of the mouse, relative to the top left of the primary display.
- **button:** Which button was pressed. 1 is left-click. 2 is right-click. 3 is middle-click.

**`mousemove`** — *Fires when the mouse cursor is moved.*\
Returns:
- **x:** The X position of the mouse, relative to the top left of the primary display.
- **y:** The Y position of the mouse, relative to the top left of the primary display.

**`mousewheel`** — *Fires when the mouse wheel is scrolled. Some trackpads may not fire this event unless "Scroll inactive windows when I hover over them" is disabled in the Windows settings.*\
Returns:
- **x:** The X position of the mouse, relative to the top left of the primary display.
- **y:** The Y position of the mouse, relative to the top left of the primary display.
- **delta:** How much the mouse wheel was scrolled. Positive numbers are considered "up" and negative numbers are "down".
- **axis:** Whether the scroll was vertical or horizontal. 0 is vertical. 1 is horizontal.

### Example

```js
const globalMKH = require("global-mkh");

globalMKH.on("keyup", data => {
  console.log("keyup: ", data);
});

globalMKH.on("keydown", data => {
  console.log("keydown", data);
});

globalMKH.on("mouseup", data => {
  console.log(data);
});

globalMKH.on("mousemove", data => {
  console.log(data);
});

globalMKH.on("mousedown", data => {
  console.log(data);
});

globalMKH.on("mousewheel", data => {
  console.log(data);
});

```

### Available functions

- **`pauseMouseEvents`** — *Pauses all mouse events.*
- **`resumeMouseEvents`** — *Resumes all mouse events.*
- **`getPaused`** — *Returns the paused state as a boolean.*

---
_Source: https://npm.io/package/@abberdeen/global-mkh · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
