nycklar
v1.0.2
Published
> A tiny proptype for keybindings, inspired by the [`tinykeys`](https://jamiebuilds.github.io/tinykeys/) lib
Readme
🔑 nycklar
A tiny proptype for keybindings, inspired by the
tinykeyslib
This is a tiny version of what tinykeys can do, and is more of a personal project than something you should use.
Usage
import { nycklar } from "nycklar";
nycklar(window, {
"Shift+D": () => {
console.log("pressed shift and d");
},
abc: () => {
console.log("pressed the abc keys in order");
},
});React Hooks Example
If you're using nycklar within a component, you should also make use of the returned cleanup() function.
import { useEffect } from "react";
import { nycklar } from "nycklar";
useEffect(() => {
let cleanup = nycklar(window, {
// ...
});
return () => {
cleanup();
};
});