Stop a key getting stuck when Shift changes it while held (#227)
Input remembered keys under KeyboardEvent.key. Pressing a, adding Shift and letting go sent "A" on release, which matched nothing, so "a" stayed down until the next release without Shift. - New rule keyName in src/core/keys.ts lowercases a single character. So a and A are the same key, also under Caps Lock. - Input remembers per physical key (e.code) under which name it went down and releases exactly that name. So 1 released as ! is freed too, which lowercasing alone does not cover. - On key down, up and held, Key is down and Axis input compare with the same rule. A node that already stores A reacts to a. - Recording a key in the inspector stores Shift+A as a. - Limit: holding Shift before pressing 1 still sends !, and a node on 1 does not react. Nothing gets stuck by it. Tests: - 3 new unit tests in tests/core/behavior-events.test.ts: the flow from the issue, 1 released as !, and a node on A hearing a. - Without lowercasing exactly the issue test and the A test fail. - Without the code memory exactly the 1/! test fails. - ./check.sh: 159 files, 2340 tests, CHECK EXIT 0 (before 2337). - No e2e change, the check sum stays at 1377. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
c1a6d63edb
commit
ffb5bbe039
5 files changed
+79
-11
No files matched your search
@@ -15,6 +15,7 @@ import {
|
||||
assetRefLabel,
|
||||
NO_ASSET_LABEL,
|
||||
} from '../../core/properties/assetRef';
|
||||
import { keyName } from '../../core/keys';
|
||||
import { FIRST_TILE_LAYER } from '../../core/model/liveTilemap';
|
||||
import { tilemapLayerNames } from '../../core/model/tilemap';
|
||||
import { isKindWith, type ReferenceKind } from '../../core/properties/kinds';
|
||||
@@ -569,7 +570,7 @@ class KeyCaptureButton extends Button {
|
||||
this.capturing = true;
|
||||
return true;
|
||||
}
|
||||
this.key = event.key;
|
||||
this.key = keyName(event.key); // Shift + A is "a", the name the game hears it by
|
||||
this.setText(keyLabel(this.key));
|
||||
this.onCapture(this.key);
|
||||
return true;
|
||||
|
||||
Reference in new issue
Block a user