diff --git a/game-runtime/src/host/boot-game-host.js b/game-runtime/src/host/boot-game-host.js index 2e5fbe77..9339dc2a 100644 --- a/game-runtime/src/host/boot-game-host.js +++ b/game-runtime/src/host/boot-game-host.js @@ -306,6 +306,11 @@ export async function bootGameHost(opts) { targetCanvas.addEventListener('pointerup', (ev) => { inputBridge._emit('pointerup', toCanvasXY(ev.clientX, ev.clientY)); }); + // 键盘桥接:挂 window(键盘无 canvas rect,坐标无关),补齐 getInput 契约的 key 两态。 + // 对齐同仓 host-dev/host.js:427-428 已有范式;W-G1 scale-20 两轮对抗诊断实证: + // 原 attachInput 漏此桥 → 所有方向键/空格游戏(2048/Tetris/Asteroids)输入永远收不到、score≈0、phase 永久 playing。 + window.addEventListener('keydown', (ev) => { unlockAudioOnce(); inputBridge._emit('keydown', { key: ev.key }); }); + window.addEventListener('keyup', (ev) => inputBridge._emit('keyup', { key: ev.key })); } /* ── RAF(stub play 模式)── */