import { useState as a, useEffect as f } from "react";
function l(u, t) {
  const [i, o] = a(!1);
  function r(e) {
    const { code: n } = e;
    n === u && (o(!0), e.preventDefault());
  }
  const s = (e) => {
    const { code: n } = e;
    n === u && (o(!1), e.preventDefault());
  };
  return f(() => {
    var e, n;
    return (e = t.current) == null || e.addEventListener("keydown", r), (n = t.current) == null || n.addEventListener("keyup", s), () => {
      var c, d;
      (c = t.current) == null || c.removeEventListener("keydown", r), (d = t.current) == null || d.removeEventListener("keyup", s);
    };
  }, [r, s]), i;
}
export {
  l as useKeyPress
};
