import { useEffect } from 'react'

export const useWindowEvent = <K extends keyof WindowEventMap>(
  event: K,
  callback: () => void
) => {
  useEffect(() => {
    window.addEventListener(event, callback, true)
    return () => window.removeEventListener(event, callback, true)
  }, [event, callback])
}
