@sjblurton/use-event-listener
TypeScript icon, indicating that this package has built-in type declarations

0.1.0 • Public • Published

useEventListener

useEventListener is a custom react hook to add and remove event listeners from the dom. First input is the listener, the second is a callback function to run when the the listener is triggered, the third is optional

To install

npm i "@sjblurton/use-event-listener"

yarn add "@sjblurton/use-event-listener"

To import the hook

import useEventListener from "@sjblurton/use-event-listener";

To call the hook...

  useEventListener("keydown", (e: KeyboardEvent) => {
    function(e.key);
  }, HTMLElement);

Links

GitHub: https://github.com/sjblurton/use-event-listener
NPM: https://www.npmjs.com/package/@sjblurton/use-event-listener

Dependencies (0)

    Dev Dependencies (13)

    Package Sidebar

    Install

    npm i @sjblurton/use-event-listener

    Weekly Downloads

    0

    Version

    0.1.0

    License

    MIT

    Unpacked Size

    10.6 kB

    Total Files

    15

    Last publish

    Collaborators

    • sjblurton