react-keycon
v0.3.0
Published
React Key Controller Hooks Component
Downloads
1,539
Maintainers
Readme
react-keycon
React Keyboard Controller
Installation
npm i react-keycon
How to use
import { useKeycon } from "keycon";
const {
isKeydown,
onBlur,
onKeydown,
onKeyup,
} = useKeycon({
// If you want to specify a specific input, use ref. If not used, the event is used for the window.
ref: containerRef,
keys: ["shift"],
});
onKeydown(() => {
console.log("keydown");
}, []);
onKeyup(() => {
console.log("keyup");
}, []);
onBlur(() => {
console.log("blur");
}, []);
return <div>{isKeydown ? "keydown" : "keyup"}</div>;