Function DocumentListener

  • Attach a document listener to the lifecycle of the current Context. The event listener will be removed when the context is destroyed.

    Type Parameters

    • TKey extends keyof DocumentEventMap

    Parameters

    • props: {
          capture?: boolean;
          on: TKey;
          options?: AddEventListenerOptions;
          then: ((this, event) => void);
      }
      • Optional capture?: boolean

        Whether to use event capturing.

      • on: TKey

        Event name.

      • Optional options?: AddEventListenerOptions

        Additional event listener options.

      • then: ((this, event) => void)

        Event handler.

          • (this, event): void
          • Parameters

            • this: Document
            • event: DocumentEventMap[TKey]

            Returns void

    Returns JSX.Element

    Example

    <DocumentListener on='keydown' then={e => handleKeydownEvent(e)}/>