Attach a typed event listener to the window, the document or an element, always calling your newest handler and removing it on cleanup.
pnpm dlx shadcn@latest add "https://ui.tealmac.com/r/use-event-listener.json"