useWindowEvent

Attach an event listener to the window and remove it when the component unmounts.

This is custom React hooks, you need to follow the Basic Rules when you use it.

General

Show the last key pressed anywhere on the page.

APIs

useWindowEvent

const useWindowEvent = <K extends keyof WindowEventMap>(
  type: K,
  listener: (event: WindowEventMap[K]) => void,
  options?: boolean | AddEventListenerOptions,
) => void
Edit this page on GitHub