webdevpuneet.com

Typing Speed Test (WPM Counter) with Levels & Daily Test

Typing Speed Test (WPM Counter) · Games · Plain HTML, CSS & JS · Live preview

CategoryGames

About this UI Snippet

Typing Speed Test — Net WPM, True Accuracy, Code Mode, Weak-Key Practice, 20 Levels and a Daily Test

Screenshot of the Typing Speed Test (WPM Counter) snippet rendered live

A good typing test measures speed and accuracy honestly, and gives you a reason to practise. This version does both. It is a timed test (15, 30, 60 or 120 seconds) with five kinds of text, a live WPM and accuracy display, a ghost caret that races your personal best, a chart of your speed over time, 20 levels with target speeds, a Daily Test with a streak and a Weak keys mode that practises the letters you miss. It is plain HTML, CSS and JavaScript with no libraries, images or audio files.

Measuring speed and accuracy properly

Words per minute is defined as correct characters divided by five, divided by minutes. correctChars() counts the characters of every word you typed correctly (plus the space after it) and the correct start of the word you are typing now, so a mistyped word does not count towards your WPM. Accuracy is different: every key press is counted as correct or wrong at the moment it is made, and a mistake stays counted even if you fix it with Backspace. That is what makes the figure honest. The test also shows the raw speed (all characters typed), and a consistency score computed from the spread of your speed second by second.

A word-based typing model

Text is a list of words, and the caret moves through the current word. Space ends the word, Backspace deletes a character, Ctrl+Backspace deletes the word, and Backspace on an empty word steps back into the previous word only if it was wrong. Extra letters typed after the end of a word are shown in red and limited to eight. Only the letters of the word you are typing are repainted on each key press, so the test stays fast, and the caret and ghost positions come from the offsets of the letter elements.

Five kinds of text, all seeded

makeSource() returns a generator for each mode: common words, sentences with punctuation, numbers (decimals, prices, dates, colours, phone numbers and percentages), real code snippets (JavaScript, CSS, HTML, SQL and shell), and a mix that adds capital letters and punctuation. A small seeded random generator (mulberry32) makes the levels and the Daily Test the same text for every player. The text is extended as you type, so a two-minute test never runs out.

Weak keys, ghost and chart

Every key press is recorded per letter (attempts and mistakes). The Weak keys mode builds its words from the letters you miss most, and the result screen lists the keys to practise. The ghost caret moves at your personal-best pace for the same test, so you can see whether you are ahead or behind as you type. After each test an SVG chart plots net WPM (solid) and raw WPM (dashed) per second, with a dot on the baseline for every mistake.

Levels, stars and the daily test

Each of the 20 levels names a mode, a duration, a target WPM and a minimum accuracy. Passing earns one star, a second star with 15 percent to spare and a third with 98 percent accuracy. Passing a level unlocks the next. The Daily Test is a 60-second mixed test from a seed based on the date, with a streak and a Copy result button. Your last 30 tests are saved and drawn as a sparkline on the menu, and all progress is saved to localStorage inside try/catch.

An on-screen keyboard that teaches

Below the text, a keyboard lights up the next key to press (and the Shift key when a capital or a symbol needs it), flashes every key you press, and tints the keys you miss most often in red, using the same per-letter statistics as the Weak keys mode. It helps beginners find the keys and shows experienced typists where their mistakes cluster.

Feel and accessibility

The text scrolls line by line to keep the caret on the second row, the caret glows and slides, and the page blurs with a "click to focus" message if the input loses focus. Typing sound is off by default and can be switched on. The game works with touch keyboards through an input fallback, scales to short preview areas and stacks on phones.

What's included

Features

Net WPM from correct characters only, true accuracy that keeps every mistake, raw WPM and a consistency score
Word-based typing model: Space commits a word, Backspace edits, Ctrl+Backspace deletes a word, extra letters shown in red
Five text modes: words, sentences, numbers, real code snippets and a mixed mode with capitals and punctuation
Weak keys mode that builds words from the letters you miss most, plus a list of keys to practise on the result screen
Ghost caret racing your personal best, and a per-second SVG chart of net and raw WPM with a dot for each mistake
20 levels in four tiers with target WPM and minimum accuracy, three stars each, unlocking one after another
Daily Test from a seeded generator with a streak and a Copy result button, and a sparkline of your last 30 tests
Timed tests of 15, 30, 60 or 120 seconds with text that extends as you type
On-screen keyboard that lights the next key (and Shift), flashes pressed keys and tints the keys you miss most
Three-line scrolling window, glowing sliding caret, a click-to-focus blur and a touch keyboard fallback
Optional Web Audio typing sounds (off by default), scaling to short preview areas, progress saved to localStorage inside try/catch

Step by step

How to Use

  1. 1
    Choose a testOn the menu, pick a mode (Words, Sentences, Numbers, Code, Mixed or Weak keys) and a duration (15, 30, 60 or 120 seconds) and press Start test. Or play the Daily Test, or start with level 1 of the 20 levels.
  2. 2
    Start typingThe clock starts with your first key. Type the words as shown: Space moves to the next word, Backspace fixes a mistake, Ctrl+Backspace deletes the whole word. Wrong letters turn red and extra letters show in dark red.
  3. 3
    Watch the live numbersWPM counts only correct characters, accuracy counts every mistake you made even if you fixed it, and Raw counts everything you typed. A purple ghost caret runs at your personal best pace for this test.
  4. 4
    Read the resultsAt the end you get your WPM, accuracy, raw speed, consistency and a chart of your speed during the test, with a dot for every mistake. A new personal best is celebrated, and the keys you miss most are listed.
  5. 5
    Pass the levelsEach level has a target WPM and a minimum accuracy. Pass with 15 percent to spare for a second star, and with 98 percent accuracy for a third. Passing a level unlocks the next one.
  6. 6
    Practise your weak keys and keep your streakChoose Weak keys to get words built from the letters you miss most. Play the Daily Test every day to build a streak, and press Tab to restart a test or Esc to return to the menu.

Real-world uses

Common Use Cases

Teaching how WPM is really calculated
The five-characters-per-word rule, net versus raw speed and the difference between WPM and accuracy are all visible in a few short functions, which makes this a good reference for anyone building a typing test or a typing tutor.
A practice tool for a developer site
The code mode types real JavaScript, CSS, HTML, SQL and shell lines, with brackets and symbols, which is what developers actually need to get faster at. The daily test and streak give people a reason to come back.
Efficient text rendering for a typing UI
Only the current word is repainted on each key press, and the caret position comes from element offsets, so the test stays smooth even with hundreds of words in the DOM.
Feedback that motivates
The ghost caret, the personal-best celebration, the error dots on the chart and the weak-key list show how to turn raw numbers into advice that makes the user want another run.
Seeded daily challenges for any skill
Generating the same text from the date makes a fair daily challenge with no backend. The same pattern fits quizzes, reaction tests and any skill game.
Related: Quick Math Arithmetic Game
See the Quick Math Arithmetic Game for another speed game with a score and a timer.
Related: Reaction Time Tester Game
See the Reaction Time Tester Game for a related skill-testing games pattern worth pairing with this one.

Got questions?

Frequently Asked Questions

Correct characters divided by five, divided by the minutes elapsed. correctChars() counts the characters (and the spaces) of the words you typed correctly, plus the correct start of the word in progress. A word with a mistake in it adds nothing, so errors lower your WPM. The Raw figure uses every character you typed, right or wrong.

Because accuracy is measured when you press each key: every key press is counted as correct or wrong at that moment and the count is never reduced by Backspace. Fixing a mistake restores your WPM but not your accuracy, which is how most serious typing tests work and why the number is honest.

Every letter you type is recorded with how often you miss it. Weak keys picks the four letters with the highest miss rate (after at least eight attempts each) and builds the test from words that contain them. The result screen also lists the keys to practise. The statistics are saved in your browser.

Each level sets a mode, a duration, a target WPM and a minimum accuracy. Reaching both passes it for one star, finishing 15 percent above the target gives a second star and 98 percent accuracy a third. The next level unlocks when the previous one is passed. The Daily Test uses a 60-second mixed text seeded from the date, so everyone types the same text, and clearing it on consecutive days builds a streak.

Add strings to the SENTENCES or CODE arrays, or words to the WORDS string. Each sentence or code line is split on spaces into words, so keep a space between tokens. To add a new mode, add an entry to MODES and a branch in makeSource() that returns a function producing words.

Yes. All localStorage access is in try/catch, so a blocked storage only means that records are not saved, and every sound call is wrapped. A hidden input captures the keyboard, and on touch devices the typed text is read from the input event as a fallback. On narrow screens the layout stacks and the page scrolls.

Copy & paste

Source Code

<div class="tw-fit" id="tw-fit"><div class="tw-wrap" id="tw-wrap">
  <div class="tw-panel" id="tw-panel">
    <div class="tw-hud">
      <div class="tw-hud-left">
        <span class="tw-kicker" id="tw-kicker">Typing Test</span>
        <span class="tw-name" id="tw-name">Pick a test</span>
      </div>
      <div class="tw-hud-btns">
        <button class="tw-btn-sm" id="tw-restart" type="button" title="Restart (Tab)">Restart <em>Tab</em></button>
        <button class="tw-btn-sm" id="tw-menu-btn" type="button" title="Menu (Esc)">Menu <em>Esc</em></button>
        <button class="tw-btn-sm" id="tw-mute" type="button" aria-pressed="true">Sound off</button>
      </div>
    </div>

    <div class="tw-stats">
      <div class="tw-stat big"><span class="tw-label">WPM</span><b id="tw-wpm">0</b></div>
      <div class="tw-stat"><span class="tw-label">Accuracy</span><b id="tw-acc">100%</b></div>
      <div class="tw-stat"><span class="tw-label" id="tw-time-label">Time</span><b id="tw-time">30</b></div>
      <div class="tw-stat"><span class="tw-label">Raw</span><b id="tw-raw">0</b></div>
      <div class="tw-stat"><span class="tw-label" id="tw-goal-label">Best</span><b id="tw-goal">-</b></div>
    </div>
    <div class="tw-progress"><div class="tw-progress-bar" id="tw-progress"></div></div>

    <div class="tw-box" id="tw-box">
      <div class="tw-view" id="tw-view"><div class="tw-text" id="tw-text"></div><i class="tw-caret" id="tw-caret"></i><i class="tw-ghost" id="tw-ghost"></i></div>
      <div class="tw-focus" id="tw-focus">Click here or just start typing</div>
      <input class="tw-capture" id="tw-input" type="text" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false" aria-label="Type here">
    </div>
    <p class="tw-hint" id="tw-hint">The clock starts with your first key. Space moves to the next word, Backspace fixes a mistake.</p>
    <div class="tw-kb" id="tw-kb" aria-hidden="true"></div>

    <div class="tw-overlay show" id="tw-menu">
      <p class="tw-logo">Typing Test</p>
      <p class="tw-tagline">Find out how fast you type, then get faster. WPM counts only correct characters, accuracy counts every mistake, even the ones you fixed.</p>
      <div class="tw-menu-row">
        <button class="tw-daily" id="tw-daily" type="button">
          <span class="tw-daily-title" id="tw-daily-title">Daily Test</span>
          <span class="tw-daily-sub" id="tw-daily-sub">60 seconds, the same text for everyone</span>
        </button>
        <div class="tw-practice">
          <span class="tw-practice-label">Free test</span>
          <div class="tw-chips" id="tw-modes"></div>
          <div class="tw-chips" id="tw-durs"></div>
          <button class="tw-start" id="tw-start" type="button">Start test</button>
        </div>
        <div class="tw-totals"><span>Best <b id="tw-best">0</b> WPM</span><span>Average <b id="tw-avg">0</b> WPM</span><span>Daily streak <b id="tw-streak">0</b></span><span><b id="tw-star-total">0</b> / 60 stars</span><svg class="tw-spark" id="tw-spark" viewBox="0 0 160 40" preserveAspectRatio="none"></svg></div>
      </div>
      <div class="tw-tiers" id="tw-tiers"></div>
    </div>

    <div class="tw-overlay" id="tw-result">
      <p class="tw-result-title" id="tw-result-title">Test complete</p>
      <div class="tw-result-stars" id="tw-result-stars"><span>&#9733;</span><span>&#9733;</span><span>&#9733;</span></div>
      <div class="tw-result-grid">
        <div><span class="tw-label">WPM</span><b id="tw-r-wpm">0</b></div>
        <div><span class="tw-label">Accuracy</span><b id="tw-r-acc">0%</b></div>
        <div><span class="tw-label">Raw</span><b id="tw-r-raw">0</b></div>
        <div><span class="tw-label">Consistency</span><b id="tw-r-con">0%</b></div>
        <div><span class="tw-label">Characters</span><b id="tw-r-chars">0</b></div>
      </div>
      <svg class="tw-chart" id="tw-chart" viewBox="0 0 400 110" preserveAspectRatio="none"></svg>
      <p class="tw-result-sub" id="tw-result-sub"></p>
      <div class="tw-result-btns">
        <button class="tw-btn" id="tw-next" type="button">Next level</button>
        <button class="tw-btn tw-btn-ghost" id="tw-retry" type="button">Try again</button>
        <button class="tw-btn tw-btn-ghost" id="tw-share" type="button">Copy result</button>
        <button class="tw-btn tw-btn-ghost" id="tw-menu-back" type="button">Menu</button>
      </div>
    </div>
  </div>
</div></div>

Extend with AI

Take This Snippet Further With AI

Paste this snippet's HTML, CSS and JS into an AI coding assistant like Claude and ask it to explain how correctChars() and the per-keystroke accuracy differ, how the word-based model handles Backspace into the previous word, and how placeCaret() keeps the caret on the second line of the three-line window. It is also a good base to extend: ask for a keyboard heat map of your slowest keys, a "stop on error" mode, quote passages with an author, a custom text box, a leaderboard for the Daily Test, or a multiplayer race on the same seeded text. You can also ask it to review the touch keyboard fallback for double input.

Prompt to recreate it

Copy this into your AI assistant of choice to build the effect from scratch, or as a jumping-off point for your own variant:

text
Build a typing speed test with levels in plain HTML, CSS and JavaScript, with no libraries, images or audio files.

Requirements:
- A timed test (15, 30, 60 or 120 seconds) that starts with the first key press and shows live WPM, accuracy, raw WPM and time left, plus a progress bar. WPM is correct characters divided by 5 per minute, where only correctly typed words (plus the space after each) and the correct start of the current word count. Accuracy counts every key press as correct or wrong when it is typed, and mistakes stay counted after Backspace. Raw WPM counts everything typed.
- A word-based model: text is a list of words in a three-line window that scrolls to keep the caret on the second line. Space commits the current word (ignored if empty), Backspace deletes a character, Ctrl+Backspace deletes the word, and Backspace on an empty word returns to the previous word only if it was wrong. Colour letters (dim, correct, wrong), show up to 8 extra letters in red, underline wrong words, and repaint only the current word on each key. Capture the keyboard with a hidden input (with a touch fallback through the input event) and blur the text with a "click to focus" message when it loses focus. Tab restarts and Esc opens the menu.
- Five seeded text modes: common words, sentences with punctuation, numbers (decimals, prices, dates, hex colours, percentages, phone numbers), code snippets (JavaScript, CSS, HTML, SQL, shell) and a mix with capitals and punctuation. Extend the text as the user types. A Weak keys mode that builds words from the letters with the highest miss rate, using per-letter statistics saved to localStorage.
- A ghost caret moving at the personal best pace for the same mode and duration, and a result screen with WPM, accuracy, raw, consistency (from per-second speed variation), characters correct/missed, a personal best celebration, the keys to practise and an SVG chart of net and raw WPM per second with a dot for each mistake.
- 20 levels in 4 tiers defined as data (mode, seconds, target WPM, minimum accuracy). Passing gives 1 star, +1 for 15 percent over the target, +1 for 98 percent accuracy, and unlocks the next level. A Daily Test (60-second mixed text from a date seed) with a day streak and a copy result button. Save progress, bests, the last 30 tests, letter statistics and the sound setting to localStorage inside try/catch, and show a sparkline of recent tests on the menu.
- Optional Web Audio key sounds (off by default), confetti on a new best or a passed level, and scale the whole game to fit the available area (down to 40 percent), stacking the layout on narrow screens.

Want to tighten it up first? Run this prompt through the AI Prompt Studio to score it across 8 quality dimensions, catch anti-patterns, and tune the wording for Claude, ChatGPT, or Gemini before you paste it in.