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

0.0.5 • Public • Published

useKeyEvent

CI Status Stars LICENSE SIZE

⌨️ A lightweight, zero-dependency React hook for detecting dynamic keyboard events. Written in TypeScript.

Installation

yarn add use-key-event
# or
npm i use-key-event

Usage

Example:

import useKeyEvent from "use-key-event";

const Home = () => {

  const handleEvent = () => {
    console.log("The enter key has been pressed.");
  };
  
    useKeyEvent("Enter", handleEvent);

  return (
    <p>
      Press the enter key and check your console!
    </p>
  );
};

export default Home;

TypeScript

useKeyEvent is written in TypeScript and comes with type definitions out-of-the-box, so using it with TypeScript in your application will be seamless and integrated.

Contributing

PR's, issues, and contributions are welcome! You can read the code of conduct here.


Created and maintained with ❤️ by @FilippoFonseca.

/use-key-event/

    Package Sidebar

    Install

    npm i use-key-event

    Weekly Downloads

    2

    Version

    0.0.5

    License

    MIT

    Unpacked Size

    9.92 kB

    Total Files

    12

    Last publish

    Collaborators

    • filippofonseca