UNPKG

use-keybinds

Version:

Lightweight keybind library for React

3 lines 440 B
"use client" import{useCallback as u,useEffect as s,useState as c}from"react";var l=()=>{let[o,n]=c(typeof window<"u"?document.activeElement:null),e=u(()=>{n(document.activeElement)},[]),t=u(()=>{n(null)},[]);return s(()=>(addEventListener("focusin",e),addEventListener("focusout",t),()=>{removeEventListener("focusin",e),removeEventListener("focusout",t)}),[e,t]),o},r=l;export{r as default}; //# sourceMappingURL=useFocusedElement.mjs.map