Doesn't this unfortunately prevent the game from running in Worker Mode? Which means that you'll lose performance/smoothness by doing it.
Hmm yeah I think that's the case. You can also edit the exported index.html though like so, which should keep the worker mode enabled I think.
But I there should be an in-engine way to handle this. A "prevent default" plugin or something, because it's one of those topics that comes up over and over again.
BTW, this code should disable all keyboard inputs, iirc including alt+F4, F12 and such.
document.addEventListener('keydown', function(event) {
event.preventDefault();
});