import { useEffect } from "react";
const useKeyboardEvent = (ref, callback, key, events = ["keydown"]) => {
	useEffect(() => {
		const element = ref.current;
		if (!element) return;
		const handleKeyboardEvent = (event) => {
			if (event.key === key || Array.isArray(key) && key.includes(event.key)) callback(event);
		};
		events.forEach((eventName) => element.addEventListener(eventName, handleKeyboardEvent));
		return () => {
			events.forEach((eventName) => element.removeEventListener(eventName, handleKeyboardEvent));
		};
	}, [
		ref,
		callback,
		events,
		key
	]);
};
export { useKeyboardEvent as t };

//# sourceMappingURL=useKeyboardEvent.js.map