upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsyfyra <258908070+syfyra@users.noreply.github.com>2026-11-26 11:08:00 +0100
committersyfyra <258908070+syfyra@users.noreply.github.com>2026-11-26 11:08:00 +0100
commit393dab2e73473e232e1dc7f42eef70d4f4d1790d (patch)
treec6f143b008f3969f110d83c33be3535519811ebf
parenta73a57e1339be072baf5522351c8ec7f1482b56b (diff)
viewer: slow flight on C instead of Ctrl (VIEWER-SLOW-KEY-CTRL-W)
The help line offered Ctrl as the slow modifier for W A S D and Q/E, but with a movement key held Ctrl makes a browser shortcut: Ctrl+W closes the tab (a page cannot cancel it in Chromium or Firefox), Ctrl+S and Ctrl+D open the save-page and bookmark dialogs and Ctrl+E moves the focus to the address bar. The keydown handler leaves modified keys to the browser, so slow flight forward lost the whole viewer, and every other slow direction left the page. Slow is now the C key, which no browser binds. Ctrl leaves the speed alone. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
-rw-r--r--tests/test_viewer_streaming.cjs12
-rw-r--r--viewer/index.html8
2 files changed, 14 insertions, 6 deletions
diff --git a/tests/test_viewer_streaming.cjs b/tests/test_viewer_streaming.cjs
index 8248181d8..5643c7c01 100644
--- a/tests/test_viewer_streaming.cjs
+++ b/tests/test_viewer_streaming.cjs
@@ -374,7 +374,11 @@ test('the bounds overlay creates helpers on the first G press and reuses them',
374 helpers.forEach((helper, i) => assert.equal(boundsGroup.children[i], helper)); 374 helpers.forEach((helper, i) => assert.equal(boundsGroup.children[i], helper));
375}); 375});
376 376
377test('Shift speeds the camera up and Ctrl slows it down, on either side of the keyboard', async () => { 377test('Shift (either side) speeds the camera up and C slows it down; Ctrl does not, and the help says so', async () => {
378 // With a movement key held, Ctrl makes browser shortcuts a page cannot all cancel: Ctrl+W closes the tab.
379 const help = html.match(/<div id="help">([\s\S]*?)<\/div>/)[1];
380 assert.match(help, /<kbd>C<\/kbd> slow/);
381 assert.doesNotMatch(help, /Ctrl/);
378 class Vector3 { 382 class Vector3 {
379 constructor(x = 0, y = 0, z = 0) { Object.assign(this, { x, y, z }); } 383 constructor(x = 0, y = 0, z = 0) { Object.assign(this, { x, y, z }); }
380 set(x, y, z) { return Object.assign(this, { x, y, z }); } 384 set(x, y, z) { return Object.assign(this, { x, y, z }); }
@@ -432,8 +436,10 @@ test('Shift speeds the camera up and Ctrl slows it down, on either side of the k
432 close(climb(), 4); 436 close(climb(), 4);
433 close(climb('ShiftLeft'), 20); 437 close(climb('ShiftLeft'), 20);
434 close(climb('ShiftRight'), 20); 438 close(climb('ShiftRight'), 20);
435 close(climb('ControlLeft'), 0.8); 439 close(climb('KeyC'), 0.8);
436 close(climb('ControlRight'), 0.8); 440 close(climb('ShiftLeft', 'KeyC'), 4);
441 close(climb('ControlLeft'), 4);
442 close(climb('ControlRight'), 4);
437 // A wheel changes the speed by 1.15 per notch; a sideways scroll (a trackpad pan, deltaX only) must not. 443 // A wheel changes the speed by 1.15 per notch; a sideways scroll (a trackpad pan, deltaX only) must not.
438 // A wheel changes the speed by 1.15 per notch; a sideways scroll (a trackpad pan, deltaX only) must not. 444 // A wheel changes the speed by 1.15 per notch; a sideways scroll (a trackpad pan, deltaX only) must not.
439 const wheel = handlers.get('wheel'); 445 const wheel = handlers.get('wheel');
diff --git a/viewer/index.html b/viewer/index.html
index 6f21002b1..99c1eece5 100644
--- a/viewer/index.html
+++ b/viewer/index.html
@@ -31,7 +31,7 @@
31 and serve with <code>python -I viewer/serve.py --world &lt;work&gt;\world</code>. 31 and serve with <code>python -I viewer/serve.py --world &lt;work&gt;\world</code>.
32</div> 32</div>
33<div id="help"> 33<div id="help">
34 <kbd>W A S D</kbd> move · <kbd>Q</kbd>/<kbd>E</kbd> down/up · <kbd>Shift</kbd> fast · <kbd>Ctrl</kbd> slow · wheel: speed<br> 34 <kbd>W A S D</kbd> move · <kbd>Q</kbd>/<kbd>E</kbd> down/up · <kbd>Shift</kbd> fast · <kbd>C</kbd> slow · wheel: speed<br>
35 <kbd>F</kbd> wireframe · <kbd>T</kbd> textures/clay · <kbd>G</kbd> chunk bounds · <kbd>R</kbd> back to spawn · <kbd>P</kbd> copy link to this view · <kbd>Esc</kbd> release mouse 35 <kbd>F</kbd> wireframe · <kbd>T</kbd> textures/clay · <kbd>G</kbd> chunk bounds · <kbd>R</kbd> back to spawn · <kbd>P</kbd> copy link to this view · <kbd>Esc</kbd> release mouse
36</div> 36</div>
37<div id="start">Click to fly</div> 37<div id="start">Click to fly</div>
@@ -242,7 +242,7 @@ addEventListener("blur", () => { keys.clear(); dragging = false; });
242const world = await loadWorld(); 242const world = await loadWorld();
243addEventListener("keydown", e => { 243addEventListener("keydown", e => {
244 keys.add(e.code); 244 keys.add(e.code);
245 // Track Ctrl for slow movement, but leave modified shortcuts to the browser. 245 // Leave modified shortcuts to the browser.
246 if (e.ctrlKey || e.metaKey || e.altKey) return; 246 if (e.ctrlKey || e.metaKey || e.altKey) return;
247 if (e.code === "KeyF" && !e.repeat) wire = !wire, applyWire(); 247 if (e.code === "KeyF" && !e.repeat) wire = !wire, applyWire();
248 if (e.code === "KeyT" && !e.repeat) clay = !clay, applyClay(); 248 if (e.code === "KeyT" && !e.repeat) clay = !clay, applyClay();
@@ -439,7 +439,9 @@ renderer.setAnimationLoop(() => {
439 const dt = Math.min(clock.getDelta(), 0.1); 439 const dt = Math.min(clock.getDelta(), 0.1);
440 camera.quaternion.setFromEuler(new THREE.Euler(pitch, yaw, 0, "YXZ")); 440 camera.quaternion.setFromEuler(new THREE.Euler(pitch, yaw, 0, "YXZ"));
441 camera.getWorldDirection(fwd); right.crossVectors(fwd, up).normalize(); 441 camera.getWorldDirection(fwd); right.crossVectors(fwd, up).normalize();
442 const v = new THREE.Vector3(), s = speed * (keys.has("ShiftLeft") || keys.has("ShiftRight") ? 5 : 1) * (keys.has("ControlLeft") || keys.has("ControlRight") ? 0.2 : 1); 442 // Slow is C, not Ctrl: with a movement key held, Ctrl makes browser shortcuts that a page cannot all cancel
443 // (Ctrl+W closes the tab; S, D and E open the save and bookmark dialogs and the address bar).
444 const v = new THREE.Vector3(), s = speed * (keys.has("ShiftLeft") || keys.has("ShiftRight") ? 5 : 1) * (keys.has("KeyC") ? 0.2 : 1);
443 if (keys.has("KeyW")) v.add(fwd); if (keys.has("KeyS")) v.sub(fwd); 445 if (keys.has("KeyW")) v.add(fwd); if (keys.has("KeyS")) v.sub(fwd);
444 if (keys.has("KeyD")) v.add(right); if (keys.has("KeyA")) v.sub(right); 446 if (keys.has("KeyD")) v.add(right); if (keys.has("KeyA")) v.sub(right);
445 if (keys.has("KeyE")) v.y += 1; if (keys.has("KeyQ")) v.y -= 1; 447 if (keys.has("KeyE")) v.y += 1; if (keys.has("KeyQ")) v.y -= 1;