useGlobalListener
API
import useGlobalListener from '@restart/hooks/useGlobalListener'useGlobalListener<K>(event: K, handler: DocumentEventHandler<K>, capture: boolean | AddEventListenerOptions) => voidAttaches an event handler outside directly to the
document, bypassing the react synthetic event system.useGlobalListener('keydown', (event) => {console.log(event.key)})Parameters
eventKThe DOM event name
handler(this: Document, ev: DocumentEventMap[K]) => anyAn event handler
captureboolean | AddEventListenerOptionsWhether or not to listen during the capture event phase
Return Value void