UNPKG

react-recipes

Version:

A React Hooks utility library containing popular customized hooks

23 lines (14 loc) 371 B
# 🥧 `useKeyPress` Adds keydown/keyup listeners to any key ## Arguments - `targetKey: String`: A key on the keyboard. Required ## Returns - `keyPressed: Bool`: true on keydown are the targetKey. ## Usage ```js import { useKeyPress } from "react-recipes"; function App() { const happyPress = useKeyPress("h"); return <div>{happyPress && "😊"}</div>; } ```