use-window-event
Adds event listener to the window object on component mount and removes the event when the component unmounts
Source
Docs
PackageIcon
Usage
The use-window-event hook adds an event listener to the window object on component mount and removes it on unmount:
Example
Search focus with ⌘ + K on macOS or Ctrl + K on Windows and Linux on the Mantine docs website:
Definition
The hook has the same definition as window.addEventListener function: