addEventListener('keydown', ... seems to crash the game from inside an event

Hello,

I actually make custom window into custom scene in my project, and I want to close these scene with a SceneManager.pop(); So basically I want to do a "press a button to continue"...
 


socket.on('event', function(res){
SceneManager.push(Scene_Token);
document.addEventListener('keyup', function(){
SceneManager.pop();
}, false);
});


(same problem with keydown event here)

I use it a similar way on an other script, but the problem don't occured...
So I guess it could be caused by something specific here, maybe the first event on end destroy the key detection of the game, or I don't know, because it seems there is no easy way to debug this case...

(after the freeze, If I press a key listened by another addEventListener, I see into FireFox console some errors likes: "event.keyIdentifier is undefined", or "this._scene is null")

Is there a better way to close a custom Scene? or a way to avoid this problem?

Original thread: https://forums.rpgmakerweb.com/threads/addeventlistener-keydown-seems-to-crash-the-game-from-inside-an-event.66176/