react-keycon
TypeScript icon, indicating that this package has built-in type declarations

0.3.0 • Public • Published

react-keycon npm version

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>;

Package Sidebar

Install

npm i react-keycon

Weekly Downloads

221

Version

0.3.0

License

MIT

Unpacked Size

38 kB

Total Files

29

Last publish

Collaborators

  • younkue