"use strict";

exports.__esModule = true;
exports["default"] = void 0;
var _react = require("react");
var ESC = 27;
var _default = exports["default"] = function _default(onEsc) {
  return (0, _react.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]);
};