UNPKG

@expofp/floorplan

Version:

Interactive floor plan library for expos and events

2 lines (1 loc) 278 B
import{useEffect as o,useRef as c}from"react";function f(e,n=!0){const t=c(e);o(()=>{t.current=e}),o(()=>{if(!n)return;const r=u=>{u.key==="Escape"&&t.current()};return document.addEventListener("keydown",r),()=>document.removeEventListener("keydown",r)},[n])}export default f;