useEventListener

    API

    import useEventListener from '@restart/hooks/useEventListener'
    • useEventListener<T, K>(eventTarget: T | () => T, event: K, listener: EventHandler<T, K>, capture: boolean | AddEventListenerOptions) => void

      Attaches an event handler outside directly to specified DOM element bypassing the react synthetic event system.

      Parameters

      • eventTargetT | () => T
      • eventK

        The DOM event name

      • listener(this: T, ev: DocumentEventMap[K]) => any
      • captureboolean | AddEventListenerOptions

        Whether or not to listen during the capture event phase

      Return Value void