Simplify and Enhance your React Development Experience with a Collection of Custom Hooks
Hooks with intuitive and easy-to-use APIs, providing a delightful development experience.
Highly customizable options to adapt the hooks according to your specific needs.
Detailed and well-organized documentation to aid in learning and using the hooks.
Reduce time spent on repetitive tasks with pre-built hooks.
Empower the creation of interactive and dynamic user interfaces.
Carefully implemented hooks to ensure efficient performance in your applications.
Well-structured and reusable hooks resulting in cleaner and organized code.
Compatible with various React versions, working in different development environments.
The library is continually evolving with new hooks being added regularly.
You can use the useKeyDown hook to handle arrow key navigation in your application. For example, let's implement a simple image gallery that allows users to navigate between images using the left and right arrow keys
Press ArrowLeft
or Ctrl + ArrowRight
useDebounce is used to set a delay for changing images
useKeyDown Docsimport { useState } from "react";
import * from "hookings";
const ImageGallery = () => {
const [currentImage, setCurrentImage] = useState<number>(0);
const [block, setBlock] = useState<boolean>(false);
const images: string[] = ["image1.jpg", "image2.jpg", "image3.jpg"];
const handleLeftArrow = () => {
if (!block) {
setCurrentImage((prevImage) =>
prevImage > 0 ? prevImage - 1 : images.length - 1
);
setBlock(true);
};
};
const handleRightArrow = () => {
if (!block) {
setCurrentImage((prevImage) =>
prevImage < images.length - 1 ? prevImage + 1 : 0
);
setBlock(true);
};
};
// Handle left arrow key press
hookings.useKeyDown("ArrowLeft", handleLeftArrow);
// Handle right arrow + ctrl key press
hookings.useKeyDown("ArrowRight", handleRightArrow, { ctrlKey: true });
// Delay to change images
hookings.useDebounce(
() => {
setBlock(false);
},
300,
[currentImage]
);
return <img src={images[currentImage]} alt={`Image ${currentImage + 1}`} />;
};