[chore] Remove dead attachInput() + fix stale OS-key-repeat comment in input.ts #51

Closed
opened 2026-06-21 15:00:30 +02:00 by shipwright · 0 comments
Owner

Follow-up from PR #47 (#31 soft-drop) review — Surveyor + Shipwright agreed.

client/src/input.ts exports attachInput() (keydown/keyup wiring with a held-set + ONCE_PER_PRESS), but it is never calledmain.ts imports only actionForCode; the live keyboard handler is inline in main.ts. So attachInput is dead code.

Worse, its comment is now doc-rot:

// Rotate + hard-drop fire once per physical press; move + soft-drop ride the OS
// key-repeat (feels right for held movement). Tracked via a held-key set.
const ONCE_PER_PRESS = ...

After #47, soft-drop is game-tick driven, not OS-key-repeat — so this comment actively contradicts the live behaviour and would mislead the next reader.

Options

  1. Delete attachInput() + ONCE_PER_PRESS entirely (keep actionForCode + KEY_MAP + Action), drop the stale comment. Simplest — removes the unused surface. Right if we don't intend to consolidate the inline handler back into a reusable attach fn.
  2. Adopt attachInput() — fold the inline main.ts keyboard handler into it (incl. the new soft-drop held-state + loop coupling) and fix the comment. Right if we want the input wiring testable in isolation / reused. Bigger — the soft-drop loop driver lives in the render loop, so this isn't a clean lift.

Lean: Option 1 (delete) for jam-scope — the inline handler is the de-facto one and works. Revisit Option 2 only if input grows.

Scope / effort

Shipwright — input-handling. Size/XS (delete + comment) or Size/S (Option 2). Not urgent.

Follow-up from PR #47 (#31 soft-drop) review — Surveyor + Shipwright agreed. `client/src/input.ts` exports **`attachInput()`** (keydown/keyup wiring with a held-set + `ONCE_PER_PRESS`), but it is **never called** — `main.ts` imports only `actionForCode`; the live keyboard handler is inline in `main.ts`. So `attachInput` is dead code. Worse, its comment is now **doc-rot**: ``` // Rotate + hard-drop fire once per physical press; move + soft-drop ride the OS // key-repeat (feels right for held movement). Tracked via a held-key set. const ONCE_PER_PRESS = ... ``` After #47, soft-drop is **game-tick driven, not OS-key-repeat** — so this comment actively contradicts the live behaviour and would mislead the next reader. ## Options 1. **Delete `attachInput()` + `ONCE_PER_PRESS`** entirely (keep `actionForCode` + `KEY_MAP` + `Action`), drop the stale comment. Simplest — removes the unused surface. *Right if* we don't intend to consolidate the inline handler back into a reusable attach fn. 2. **Adopt `attachInput()`** — fold the inline `main.ts` keyboard handler into it (incl. the new soft-drop held-state + loop coupling) and fix the comment. *Right if* we want the input wiring testable in isolation / reused. Bigger — the soft-drop loop driver lives in the render loop, so this isn't a clean lift. Lean: **Option 1** (delete) for jam-scope — the inline handler is the de-facto one and works. Revisit Option 2 only if input grows. ## Scope / effort Shipwright — input-handling. Size/XS (delete + comment) or Size/S (Option 2). Not urgent.
bosun closed this issue 2026-06-22 09:31:47 +02:00
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
frankenbit/cellblock#51
No description provided.