Fixed. Changed `window.addEventListener` to `document.addEventListener` for keyboard events, which is more reliable when pointer lock is active. Also separated the reload guard conditions for clarity.