# hotcakey

> the cross-platform global shortcut (aka hotkey) module for node.js and electron

Latest version **0.8.0** (published 2021-10-23) · MIT license · 0 weekly downloads

## Install

```sh
npm install hotcakey
pnpm add hotcakey
yarn add hotcakey
bun add hotcakey
```

## Health

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

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.8.0 |
| Published | 2021-10-23 |
| First published | 2021-09-26 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 3 |
| Unpacked size | 79.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | yes |
| Author | daylilyfield |
| Maintainers | daylilyfield |
| Keywords | hotkey, shortcut, electron, keyhook, keyboard, keydown, keyup |

## Links

- npm: https://www.npmjs.com/package/hotcakey
- Homepage: https://github.com/daylilyfield/hotcakey
- Issues: https://github.com/daylilyfield/hotcakey/issues
- npm.io page: https://npm.io/package/hotcakey

## Dependencies (3)

- [bindings](https://npm.io/package/bindings.md) ^1.5.0
- [node-gyp](https://npm.io/package/node-gyp.md) ^8.1.0
- [node-addon-api](https://npm.io/package/node-addon-api.md) ^4.2.0

## Alternatives

- [@regle/core](https://npm.io/package/@regle/core.md) — 47.0K weekly downloads
- [typeof-arguments](https://npm.io/package/typeof-arguments.md) — 12.5K weekly downloads
- [@lokalise/projects-engine-contracts](https://npm.io/package/@lokalise/projects-engine-contracts.md) — 978 weekly downloads
- [@osjwnpm/nam-laboriosam-quibusdam](https://npm.io/package/@osjwnpm/nam-laboriosam-quibusdam.md) — 70 weekly downloads
- [@oridune/validator](https://npm.io/package/@oridune/validator.md) — 16 weekly downloads

## Recent versions

- 0.8.0 (latest) — 2021-10-23
- 0.5.1 — 2021-10-21
- 0.5.0 — 2021-10-17
- 0.1.0 — 2021-09-26

## README

# 🥞 hotcakey 🥞

hotcaKey is the global shortcut (aka hotkey) module for node.js and electron.

hotcakey is now actively under deploment, so api may have breaking changes even in a short term.

## motivation

i need to detect global shortcut `keydown` and `keyup` events on electron platform. i found a few solution such as [iohook](https://github.com/wilix-team/iohook/). iohook is the excellent module but too powerfull for me. i want to know only key events which has the predetermined combination.

## feature

- detecting key combination globally even if your application does not have a focus.
- using [web-standard physical keycodes](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/code/code_values)
- working with node.js and electron.
- working on macOS, windows. (and linux for near future)

## install

```sh
npm i hotcakey
```

if you use hotcakey with electron, you may need to run [electron-rebuild](https://github.com/electron/electron-rebuild).

## usage

```typescript
import hotcakey from 'hotcakey'

async function main() {
  await hotcakey.activate()

  hotcakey.register(['Shift', 'Space'], (event) => {
    console.log('%s event at %d', event.type, event.time)
  })
}

main()
```

## examples

please check out the [./examples](./examples) directory. you can find some examples for [node.js](./examples/node) and [electron](./examples/electron) there. if you would like to run examples on your computer, please clone this repository, open your terminal, and then input the commands below.

```sh
# run node.js example
npm run examples:node

# run electron example
npm run examples:electron
```

## available physical keycodes

hotcakey uses physical keycodes defiend in web standard. see type definitions [here](./src/index.ts) for detail.

## supported os

- [x] macOS 10.7 or higher
- [x] windows 10 or higher
- [ ] linux

## supported platform

- [x] node.js 14.14 or higher
- [x] electron 14 or higher

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