import { useEffect } from "react";
var ESC = 27;
export default (function (onEsc) {
  return useEffect(function () {
    if (!onEsc) return;
    var onKeydown = function onKeydown(event) {
      if (event.keyCode === ESC) {
        onEsc(event);
      }
    };
    document.addEventListener("keydown", onKeydown);
    return function () {
      return document.removeEventListener("keydown", onKeydown);
    };
  }, [onEsc]);
});