0.0.5 • Published 3 years ago
use-key-event v0.0.5
useKeyEvent
⌨️ 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.