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.
Show the last key pressed anywhere on the page.
const useWindowEvent = <K extends keyof WindowEventMap>(
type: K,
listener: (event: WindowEventMap[K]) => void,
options?: boolean | AddEventListenerOptions,
) => void