made the following function to detect pressing of escape button when in fullscreen mode.
import KeyboardEventHandler from "react-keyboard-event-handler";
import React from "react";
const handleKeyboard = (key, e) => {
e.preventDefault();
if (key === "esc") {
console.log("esc");
}
};
const ComponentA = (props) => (
<KeyboardEventHandler
handleKeys={["all"]}
onKeyEvent={handleKeyboard}
/>
);
export default ComponentA;