@hotk/hotk
v0.0.5
Published
Powerful and minimal library for managing global and contextual hotkeys on desktop platforms.
Downloads
8
Maintainers
Readme
@hotk/hotk
hotk is a lightweight and ergonomic library for managing advanced hotkeys on desktop platforms. It provides a declarative and expressive API to register key combinations, define actions, chain subactions, and detect patterns like double presses or complex sequences.
| Platform | Supported | Tested | | -------- | :-------: | :----: | | Windows | ✅ | ✅ | | macOS | ❓ | ❌ | | Linux | ❓ | ❌ |
Install
npm install @hotk/hotkBasic usage
import { hotKey, KeyCodes, Mods, Stroke } from "@hotk/hotk";
hotKey([Mods.Control], KeyCodes.KeyA)
.action(() => console.log("ctrl a"))
.stroke(Stroke.Double)
.subaction(
hotKey([], KeyCodes.KeyB)
.action(() => console.log("b"))
.subaction(hotKey([], KeyCode.KeyZ).action(() => console.log("z")))
)
.subactionsTimeout(1000)
.register();
hotKey([], KeyCodes.Escape)
.action(() => console.log("escape"))
.stroke(Stroke.Double)
.global(true)
.register();