commit 753ff28c4fd8b10fe2329c4c0199b62ca48308a3
parent 474e67ceba40bf119a7df75e73ae9ad359942f54
Author: anon <anon@example.com>
Date: Sat, 28 Nov 2026 08:00:57 +0000
Keep F1 self-targeting in the focused browser game
Diffstat:
4 files changed, 23 insertions(+), 10 deletions(-)
diff --git a/client/browser/index.html b/client/browser/index.html
@@ -1225,8 +1225,8 @@ show();
event.preventDefault();
closeChat(true);
}
- } else if (gameReady && document.activeElement === canvas && event.key === 'Tab') {
- // Keep target cycling in the game while SDL receives the original key.
+ } else if (gameReady && document.activeElement === canvas && (event.key === 'Tab' || event.key === 'F1')) {
+ // Let SDL handle targeting without moving browser focus or opening Help.
event.preventDefault();
} else if (gameReady && document.activeElement === canvas && type === 'keypress' &&
(event.key === '/' || event.key === "'")) {
diff --git a/client/tests/browser_controls.mjs b/client/tests/browser_controls.mjs
@@ -338,6 +338,19 @@ test('Tab stays in the focused game and still reaches native key handlers', () =
assert.deepEqual(game.keys, []);
});
+test('F1 reaches the focused game and cancels browser Help', () => {
+ const game = page();
+ const event = new Event('keydown', {cancelable: true});
+ event.key = 'F1';
+ const delivered = [];
+ game.window.addEventListener('keydown', event => delivered.push(event.key));
+
+ game.window.dispatchEvent(event);
+
+ assert.equal(event.defaultPrevented, true);
+ assert.deepEqual(delivered, ['F1']);
+});
+
test('Firefox Quick Find keys reach native chat without opening browser search', () => {
const game = page();
const delivered = [];
@@ -356,14 +369,14 @@ test('Firefox Quick Find keys reach native chat without opening browser search',
assert.deepEqual(game.characters, []);
});
-test('Tab and Quick Find retain normal behavior outside the ready game canvas', () => {
+test('Tab, F1 and Quick Find retain normal behavior outside the ready game canvas', () => {
for (const scenario of ['loading', 'options', 'chat', 'button']) {
const game = page({ready: scenario !== 'loading'});
if (scenario === 'options') game.fire('#menu-button', 'click');
if (scenario === 'chat') game.fire('#chat-button', 'click');
if (scenario === 'button') game.element('#menu-button').focus();
game.keys.length = 0;
- for (const [type, key] of [['keydown', 'Tab'], ['keypress', '/'], ['keypress', "'"]]) {
+ for (const [type, key] of [['keydown', 'Tab'], ['keydown', 'F1'], ['keypress', '/'], ['keypress', "'"]]) {
const event = new Event(type, {cancelable: true});
Object.assign(event, {key});
game.window.dispatchEvent(event);
diff --git a/server/assets/client/build.json b/server/assets/client/build.json
@@ -1,6 +1,6 @@
{
- "source_commit": "847df7def13a3ee96cc8a3cbbcfefc537336e186",
- "source_sha256": "de0ce8f14f03e366c7a3562ea3524f2a99384515d8f07bddeaf702ab4bd7c2a8",
+ "source_commit": "474e67ceba40bf119a7df75e73ae9ad359942f54",
+ "source_sha256": "23e6f2761bb5f205b5d1fe52a0fe4eba65c82311548e0df9a9ff455178ad8855",
"compiler": "emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 6.0.12 (5488e0871d46d19a3209988190fa6a653126256f)",
"files": {
"game.js": {
@@ -12,8 +12,8 @@
"sha256": "256723c32e39974086d45c728bfeb40de2689cd349dd5e805e43cf72b3c2d904"
},
"index.html": {
- "bytes": 66521,
- "sha256": "4b0f8ae0ccda5f8bad9afa9266f1fdf7eee8cff3b7e0422730cbdea08bb15717"
+ "bytes": 66554,
+ "sha256": "b08c122e80b20dcf48bbb8551cbbedef87fb11f767a3f1146a9465e14d543353"
},
"profile-worker.js": {
"bytes": 4673,
diff --git a/server/assets/client/index.html b/server/assets/client/index.html
@@ -1225,8 +1225,8 @@ show();
event.preventDefault();
closeChat(true);
}
- } else if (gameReady && document.activeElement === canvas && event.key === 'Tab') {
- // Keep target cycling in the game while SDL receives the original key.
+ } else if (gameReady && document.activeElement === canvas && (event.key === 'Tab' || event.key === 'F1')) {
+ // Let SDL handle targeting without moving browser focus or opening Help.
event.preventDefault();
} else if (gameReady && document.activeElement === canvas && type === 'keypress' &&
(event.key === '/' || event.key === "'")) {