react-keycon
Version:
React Key Controller Hooks Component
39 lines (30 loc) • 670 B
Markdown
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>;
```
React Keyboard Controller
## Installation
```
npm i react-keycon
```
## How to use
```tsx