DEV Community

dev truth
dev truth

Posted on Fully Autonomous

A typing score is a data contract: lessons from a browser-based tutor

A typing tutor looks simple: show a character, listen for a key, move the cursor. The score becomes much less simple when someone holds a key, switches tabs, makes a mistake, or practices text through a different input scheme.

While building EasyTyping, I found it useful to treat the score as a contract between input handling, lesson progress, timing, and storage. Here are the decisions that make that contract explicit.

1. Define an attempt before calculating accuracy

EasyTyping uses a fixed sequence. A correct key advances the cursor by one position. An incorrect key increments the attempt and error counts, but leaves the cursor where it is. The learner must enter the required key to continue.

Imagine that the target is “fj” and the learner enters “f, x, j”. There are three scored attempts, two correct attempts, and one error. The lesson is complete, but accuracy is 2 / 3, about 66.7%. Counting only the two characters that remain in the completed sequence would erase the mistake.

Backspace does not rewind this exercise. That is a deliberate lesson rule; a free-text typing test could choose a different rule. The important part is that the score and the visible cursor obey the same policy.

2. Keep browser events out of the scoring model

Not every keyboard event is a typing attempt. The input handler filters system shortcuts, held-key repeat events, modifier keys, and IME composition before passing a supported character to the scoring engine.

This prevents holding a key from appearing to be a series of deliberate successful attempts. It also prevents a shortcut such as copying text from quietly becoming a lesson error.

The current courses score fixed keyboard sequences: English QWERTY, specified pinyin or romaji, Telex sequences, and InScript key mappings. That is a narrower contract than accepting arbitrary text from an input method. For example, a displayed romaji sequence is not a promise to recognize every equivalent spelling or perform Japanese conversion.

3. Name the denominator in WPM

In this tutor, speed is correct scored keys divided by five, divided by active minutes. With 250 correct keys in two active minutes, the result is 25 WPM.

The five-key unit is a normalization convention. It does not mean the learner typed 50 dictionary words. For pinyin, romaji, Telex, and InScript exercises, it remains a measure of the required key sequence, rather than a count of native-language words.

The interface shows zero WPM when active time is below one second. Otherwise, a nearly instantaneous first event could produce a distracting number that says little about the lesson.

The EasyTyping guide to typing results gives worked examples and explains the practice conditions behind these numbers.

4. Make pause behavior precise

The clock starts with the first scored key, including an incorrect one. Locating a new key during the introduction does not start it.

A hidden page pauses immediately. A visible page with no scored input stops accumulating time after 30 seconds of inactivity; those first 30 seconds still count. Input resumes the clock without adding the remaining idle interval. Losing focus alone is not an immediate pause.

For instance, if the last key arrives at second 10 and the next arrives at second 100, the visible idle interval contributes at most 30 seconds, not 90. The clock resumes at second 100.

Elapsed intervals use a monotonic clock. Calendar dates use local wall time. These are different jobs: elapsed duration should resist a system-clock adjustment, while a practice day should follow the learner's local date.

5. Aggregate counts, not displayed percentages

Suppose one round contains 10 correct attempts out of 10, and another contains 50 correct attempts out of 100. Their accuracies are 100% and 50%.

Averaging those percentages gives 75%. Combining the actual counts gives 60 / 110, about 54.5%. The latter describes the total attempted work. The same principle applies to speed: add correct keys and active time, then calculate the combined rate.

EasyTyping stores counts and active time in the browser, including interrupted rounds. Completed lesson IDs are separate from score history. An old completion marker cannot supply a practice date, an accuracy value, or a duration that was never recorded.

What I would test first

  • A wrong key changes attempts and errors, but not cursor position.
  • The correct replacement advances exactly once.
  • Ignored browser events leave the scoring state unchanged.
  • A hidden interval contributes no additional active time.
  • A long visible idle interval stops at the inactivity threshold.
  • A combined accuracy is calculated from combined counts.
  • An interrupted round keeps the work already recorded.

These cases are more useful than checking whether a WPM label appears. They describe what the number actually means.

A tutor can use different rules and still be coherent. The failure is leaving those rules implicit while presenting the resulting scores as interchangeable.

Disclosure: I build EasyTyping. This article was generated with AI and checked against the current implementation and published practice guide.

Top comments (0)