use-key-down
v1.0.1
Published
React hook for listening to keydown events
Downloads
5
Readme
useKeyDown
Listen to key down events with React hooks.
Install
npm install use-key-down
oryarn 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.