Skip to content

fix(EasterEgg): eliminate key-repeat and load-race bugs in the typing game and Konami code - #462

Merged
shinya merged 7 commits into
Bokuchi-Editor:developfrom
tanahiro2010:fix/typing_game_bugs
Aug 9, 2026
Merged

fix(EasterEgg): eliminate key-repeat and load-race bugs in the typing game and Konami code#462
shinya merged 7 commits into
Bokuchi-Editor:developfrom
tanahiro2010:fix/typing_game_bugs

Conversation

@tanahiro2010

@tanahiro2010 tanahiro2010 commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Guard TypingGame's keydown handler against OS key-repeat (e.repeat), which was letting a single held keypress register as multiple typed characters, corrupting combo/score and mis-firing typos.
  • Block startGame() until the async high-score load resolves, so a fast round finished before the store read completes no longer overwrites a genuinely higher saved high score with a lower one.
  • Apply the same key-repeat guard to useKonamiCode, where a held key could otherwise silently reset the whole 10-key sequence (worse than the typing game case, since one bad repeat wipes all prior progress with no feedback).

Why

All three bugs share the same root cause: neither keydown handler checked e.repeat, so holding a key slightly too long — very easy to do by accident — produced synthetic repeated keydown events that the game/hook logic wasn't designed to expect.

Test plan

  • Hold a correct letter down in the typing game and confirm it registers as a single keystroke, not several
  • Finish a round quickly right after app launch (before the high-score load would normally resolve) and confirm the previous high score isn't overwritten by a lower one
  • Hold one of the Konami sequence keys (e.g. b) slightly too long and confirm the sequence progress isn't reset

…r load

Starting a round before the async high-score load resolved defaulted
highScore to 0, so a fast game always looked like a new record and
overwrote a genuinely higher saved score. Block game start until the
load finishes.
Copilot AI review requested due to automatic review settings August 1, 2026 02:10
@tanahiro2010 tanahiro2010 changed the title Prevent duplicate inputs and high score overwriting in game fix: Prevent duplicate inputs and high score overwriting in game Aug 1, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves TypingGame input reliability and high score correctness by ensuring the saved high score is loaded before gameplay begins and by suppressing auto-repeat keydown events that can cause unintended extra inputs.

Changes:

  • Added a highScoreLoaded flag in the game ref state and set it after the high score load attempt finishes (success or failure).
  • Prevented startGame() from running until the high score load has completed.
  • Ignored repeated keydown events (KeyboardEvent.repeat) to avoid duplicate character inputs when a key is held down.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@tanahiro2010 tanahiro2010 changed the title fix: Prevent duplicate inputs and high score overwriting in game fix(typing_game): Prevent duplicate inputs and high score overwriting in game Aug 1, 2026
@tanahiro2010 tanahiro2010 changed the title fix(typing_game): Prevent duplicate inputs and high score overwriting in game fix(EasterEgg): Prevent duplicate inputs and high score overwriting in game Aug 1, 2026
@tanahiro2010 tanahiro2010 changed the title fix(EasterEgg): Prevent duplicate inputs and high score overwriting in game fix(EasterEgg): eliminate key-repeat and load-race bugs in the typing game and Konami code Aug 1, 2026
@shinya
shinya changed the base branch from main to develop August 5, 2026 16:51
@shinya
shinya merged commit add2845 into Bokuchi-Editor:develop Aug 9, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants