Describe the bug
In the Falling Words game, pressing Tab moves focus away from the hidden <input> that captures keyboard events. If Enter is then pressed, whatever element now has focus is activated — typically the GitHub link in the footer. This opens GitHub in a new tab.
When the user returns to the game tab, the game may have ended (via visibilitychange -> endGame()), showing the "enter to restart" overlay. However, pressing Enter does nothing because the hidden input no longer has focus — the handleKeyDown listener is never reached.
To Reproduce
- Go to the Falling Words game
- Press Tab (focus moves away from the hidden input)
- Press Enter (GitHub opens in a new tab)
- Close the GitHub tab and return to the game
- See the "enter to restart" overlay
- Press Enter -- nothing happens
Expected behavior
- Pressing Enter on the game-over overlay should restart the game regardless of what element has focus (or the hidden input should be automatically refocused).
- Tab should not be able to steal focus from the game input.
Root cause
The hidden input in apps/frontend/src/features/games/falling-words/view.tsx:59-69 has no tabindex management. When focus leaves it via Tab, the handleKeyDown handler in engine.ts no longer receives keyboard events. The "enter to restart" prompt in game-over.tsx is purely visual -- it relies on the hidden input being focused.
Suggested fixes (one of)
- Add
tabindex={-1} to the hidden input to prevent Tab from leaving it
- Refocus the input when game-over or idle phase is entered
- Add a window-level keydown listener for Enter during game-over/idle phases
Describe the bug
In the Falling Words game, pressing Tab moves focus away from the hidden
<input>that captures keyboard events. If Enter is then pressed, whatever element now has focus is activated — typically the GitHub link in the footer. This opens GitHub in a new tab.When the user returns to the game tab, the game may have ended (via visibilitychange -> endGame()), showing the "enter to restart" overlay. However, pressing Enter does nothing because the hidden input no longer has focus — the handleKeyDown listener is never reached.
To Reproduce
Expected behavior
Root cause
The hidden input in
apps/frontend/src/features/games/falling-words/view.tsx:59-69has notabindexmanagement. When focus leaves it via Tab, the handleKeyDown handler in engine.ts no longer receives keyboard events. The "enter to restart" prompt in game-over.tsx is purely visual -- it relies on the hidden input being focused.Suggested fixes (one of)
tabindex={-1}to the hidden input to prevent Tab from leaving it