Skip to content

Files

Latest commit

a0ba145 Β· Jan 9, 2020

History

History
23 lines (14 loc) Β· 371 Bytes

useKeyPress.md

File metadata and controls

23 lines (14 loc) Β· 371 Bytes

πŸ₯§ 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

import { useKeyPress } from "react-recipes";

function App() {
  const happyPress = useKeyPress("h");

  return <div>{happyPress && "😊"}</div>;
}