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
@@ -0,0 +1,8 @@
|
||||
/**
|
||||
* The name a key goes by in the graph: `KeyboardEvent.key`, with a single character lower-cased.
|
||||
* Shift and Caps Lock turn "a" into "A" on the way down or up, but it is still the same key –
|
||||
* without this, a key pressed as "a" and let go as "A" would stay held (#227).
|
||||
*/
|
||||
export function keyName(key: string): string {
|
||||
return key.length === 1 ? key.toLowerCase() : key;
|
||||
}
|
||||
Reference in new issue
Block a user