umbr-key-master
v1.0.6
Published
A lightweight, type-safe TypeScript library for managing complex keyboard shortcuts and multi-key combinations in the browser.
Downloads
373
Maintainers
Readme
KeyMaster
A lightweight, type-safe TypeScript library for managing complex keyboard shortcuts and multi-key combinations in the browser.
npm i umbr-key-masterExample usage
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>KeyMaster Popup Test</title>
</head>
<body>
<h1>KeyMaster Popup Test</h1>
<p>Press the keys below to see popups:</p>
<ul>
<li>Escape → Alert "Escape key pressed!"</li>
<li>Control + q → Alert "Control + q pressed!"</li>
</ul>
<script type="module">
import { KeyMaster } from "../dist/index.js";
const km = new KeyMaster();
// ---- Single key: Escape ----
km.add(["Escape"], () => {
alert("Escape key pressed!");
});
// ---- Multi-key: Control + S ----
km.add(["Control", "q"], () => {
alert("Control + q pressed!");
});
</script>
</body>
</html>import { KeyMaster } from "umbr-key-master";
const km = new KeyMaster();
// ---- Single key: Escape ----
km.add(["Escape"], () => {
alert("Escape key pressed!");
});
// ---- Multi-key: Control + S ----
km.add(["Control", "q"], () => {
alert("Control + q pressed!");
});