import { useRef as a, useEffect as m } from "react";
const l = (t, s, r = ["keydown"], o = document) => {
  const n = a([]);
  m(() => {
    const c = typeof t == "string", f = c ? s : t, u = (e) => {
      c ? e.key === t && f(e) : f(e);
    };
    n.current.push(u);
    const i = (e) => {
      for (const d of n.current)
        d(e);
    }, y = Array.isArray(r) ? r : ["keydown"];
    for (const e of y)
      o.addEventListener(e, i);
    return () => {
      for (const e of y)
        o.removeEventListener(e, i);
      n.current = n.current.filter((e) => e !== u);
    };
  }, [t, s, r, o]);
};
export {
  l as default
};
//# sourceMappingURL=useKey.js.map
