⌨️ A lightweight, zero-dependency React hook for detecting dynamic keyboard events. Written in TypeScript.
yarn add use-key-event
# or
npm i use-key-event
use-key-event
is lightweight and carries no extra dependencies, making it perfect for building production applications and dkeeping them light.
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;
use-key-event
is written in TypeScript (statically-typed) and comes with type definitions out-of-the-box, so using it with TypeScript in your application (even in production-grade environments) will be seamless and integrated.
PRs, issues, and contributions are welcome! You can read the code of conduct here.
Created and maintained with ❤️ by @FilippoFonseca.