@sjblurton/use-event-listener
v0.1.0
Published
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
Downloads
1
Maintainers
Readme
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