react-custom-tours
Version:
A library with tips that you can attach to blocks on your sites so that users can more easily understand how to use your site
15 lines (14 loc) • 361 B
JavaScript
import { useRef as c, useEffect as s } from "react";
const f = (e, n) => {
const r = c(n);
r.current = n, s(() => {
if (!e) return;
const t = (o) => {
o.code === "Escape" && r.current();
};
return window.addEventListener("keydown", t), () => window.removeEventListener("keydown", t);
}, [e]);
};
export {
f as useEscapeListener
};