Skip to content

Commit

Permalink
start timer on first correct keypress
Browse files Browse the repository at this point in the history
  • Loading branch information
dustin-ward committed Mar 7, 2024
1 parent e00d826 commit 9595ad9
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions internal/app/typing.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package app

import (
"time"

tea "github.com/charmbracelet/bubbletea"
"github.com/dustin-ward/termtyping/internal/character"
)
Expand Down Expand Up @@ -31,6 +33,9 @@ func typingHandler(m AppModel, msg tea.Msg) (tea.Model, tea.Cmd) {

if keypress == m.chars[m.pos].Val {
m.stats.NumCorrect++
if m.pos == 0 {
m.stats.TimeStarted = time.Now()
}

m.chars[m.pos].State = character.CorrectState
m.pos++
Expand Down

0 comments on commit 9595ad9

Please sign in to comment.