File tree Expand file tree Collapse file tree 2 files changed +25
-0
lines changed
Expand file tree Collapse file tree 2 files changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -149,6 +149,27 @@ func (g *TypingGame) AddCharacter(char rune) {
149149 }
150150}
151151
152+ // HandleEnterKey handles Enter key press for line progression
153+ func (g * TypingGame ) HandleEnterKey () bool {
154+ if g .IsFinished || g .IsTimeUp () {
155+ return false
156+ }
157+
158+ lineText := []rune (g .DisplayLines [0 ])
159+
160+ // Only allow Enter to progress if at end of line
161+ if g .CurrentPos == len (lineText ) {
162+ // Treat Enter like Space internally for consistency
163+ g .UserInput += " "
164+ g .CurrentPos ++
165+ g .GlobalPos ++
166+ g .shiftLines ()
167+ return true
168+ }
169+
170+ return false
171+ }
172+
152173// shiftLines moves to the next line in the game, updating the words typed and generating new lines
153174func (g * TypingGame ) shiftLines () {
154175 // Move to next line
Original file line number Diff line number Diff line change @@ -24,6 +24,10 @@ func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
2424 m .restartTest ()
2525 return m , tickCmd ()
2626 }
27+ // Handle Enter for line progression
28+ if m .game .HandleEnterKey () {
29+ return m , nil
30+ }
2731 return m , nil
2832
2933 case " " :
You can’t perform that action at this time.
0 commit comments