Skip to content

Latest commit

 

History

History
25 lines (20 loc) · 434 Bytes

useListenKeyboard.md

File metadata and controls

25 lines (20 loc) · 434 Bytes

useAsyncEffect

Usage

import { useListenKeyboard } from "default-hooks";

const Demo = () => {
  const [clickCount, setClickCount] = React.useState < number > 0;

  useListenKeyboard({
    key: "b",
    handler: () => {
      setClickCount(clickCount + 1);
    }
  });

  return (
    <div>
      <h1>Feel free and click "b" key in your keyboard</h1>
      <h2>You clicked {clickCount} now!</h2>
    </div>
  );
};