import { useEffect } from "react";

const useMapResizeKeybindings = toggleMapSize => {
  useEffect(() => {
    const listener = event => {
      if (event.code === "Escape") {
        toggleMapSize();
      }
    };
    document.addEventListener("keydown", listener, false);
    return () => document.removeEventListener("keydown", listener, false);
  }, [toggleMapSize]);
};

export default useMapResizeKeybindings;
