use window.addEventListener