use-key-down
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

useKeyDown Tweet version minzipped size downloads build

Listen to key down events with React hooks.

Install

  • npm install use-key-down or
  • yarn add use-key-down

Use

import useKeyDown from 'use-key-down';

function App() {
  const isEnterKeyDown = useKeyDown('Enter');
  return <p>The Enter key is {isEnterKeyDown ? 'down' : 'up'}.</p>;
}

API

useKeyDown only takes one parameter, a string representing the key to which you want to listen to key down events.

Sponsor 💗

If you are a fan of this project, you may become a sponsor via GitHub's Sponsors Program.

Dependencies (0)

    Dev Dependencies (25)

    Package Sidebar

    Install

    npm i use-key-down

    Weekly Downloads

    2

    Version

    1.0.1

    License

    MIT

    Unpacked Size

    8.98 kB

    Total Files

    6

    Last publish

    Collaborators

    • charlesstover