@lindeneg/on-key
TypeScript icon, indicating that this package has built-in type declarations

1.1.4 • Public • Published

@lindeneg/on-key

typescript bundle-size license

Sandbox


React hook to listen for key-strokes and then do something

Installation

yarn add @lindeneg/on-key


Arguments

Name Required Default Type Description
key Y - string KeyboardEvent.key to listen after
callback Y - (event: KeyboardEvent) => void function to be called when desired event is dispatched
type N "keydown" "keydown" | "keyup" | "pressed" event type to listen after

Usage

import useOnKey from '@lindeneg/on-key';

function SomeComponent() {
  useOnKey('ArrowRight', (event) => console.log('ArrowRight: keydown', event));
}

Package Sidebar

Install

npm i @lindeneg/on-key

Weekly Downloads

1

Version

1.1.4

License

MIT

Unpacked Size

4.24 kB

Total Files

6

Last publish

Collaborators

  • christianlindeneg