Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

react-keycon

daybrush797MIT0.3.0TypeScript support: included

React Key Controller Hooks Component

key, keycode, keyboard, component, esm

readme

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

changelog

Change Log

All notable changes to this project will be documented in this file. See Conventional Commits for commit guidelines.

0.2.2 (2022-10-19)

:rocket: New Features

:mega: Other

  • update packages versions (07f0b13)

0.2.0 (2022-09-24)

:rocket: New Features

:bug: Bug Fix

  • disable keydown on blur (121f85a)

:mega: Other

  • update packages versions (94156a3)

0.1.2 (2022-07-23)

:bug: Bug Fix

0.1.0 (2022-07-23)

:rocket: New Features

:mega: Other

  • fix package.json scripts (36742de)