diff --git a/shell.html b/shell.html
index e5d74e9..8cb3d19 100644
--- a/shell.html
+++ b/shell.html
@@ -9,6 +9,7 @@
html, body {
margin: 0;
height: 100%;
+ overflow: hidden;
background: #05070d;
color: #7c8798;
font: 14px/1.5 system-ui, sans-serif;
@@ -58,6 +59,19 @@
};
unlockEvents.forEach((type) => addEventListener(type, unlockAudio, true));
+ // Arrow keys and Space also scroll the page by default. Cancel that
+ // while the game canvas has focus, but keep modified keys for browser
+ // shortcuts.
+ const gameCanvas = document.getElementById('canvas');
+ const scrollKeys = new Set([
+ 'ArrowUp', 'ArrowDown', 'ArrowLeft', 'ArrowRight', 'Space',
+ ]);
+ addEventListener('keydown', (event) => {
+ if (event.ctrlKey || event.metaKey || event.altKey) return;
+ if (event.target !== gameCanvas && document.activeElement !== gameCanvas) return;
+ if (scrollKeys.has(event.code)) event.preventDefault();
+ }, { capture: true });
+
var Module = {
canvas: document.getElementById('canvas'),
print: console.log.bind(console),