Attach the listener for events to the window instead of the Scene.