How I Built an Open Online Typing Game Platform with Real-Time 1v1 Multiplayer in React
Over the past few months, I set out to build TypingGame.in — an interactive, completely free online typing academy and arcade game portal.
While platforms like Monkeytype and TypeRacer dominate the market, I wanted to build something that blended educational touch-typing curriculums, real-time 1v1 PvP racing, and arcade gameplay (car racing, bubble popping, and zombie defense) into a single cohesive web application.
Here is a breakdown of how the architecture works, how WPM is calculated accurately, and how real-time 1v1 sync is handled.
1. Calculating Standardized WPM & Accuracy in Real-Time
A common issue in novice typing tests is treating each space-separated word as a single unit. In professional and government certification standards (such as SSC CGL and RRB), typing speed is universally standardized to 5 keystrokes = 1 standard word.
Here is the exact formula implemented in the speed test engine:
$$\text{Gross WPM} = \frac{\text{Total Characters Typed} / 5}{\text{Time Elapsed in Minutes}}$$
$$\text{Net WPM} = \max\left(0, \frac{\text{Correct Characters} / 5}{\text{Time Elapsed in Minutes}}\right)$$
$$\text{Accuracy %} = \left(\frac{\text{Correct Characters}}{\text{Total Characters Typed}}\right) \times 100$$
By evaluating velocity against Date.now() timestamps rather than relying on setInterval tick counts, the speedometer remains immune to browser background throttling or tab switches.
2. Dual-Engine Architecture: Desktop Keyboard vs. Mobile Virtual Keyboards
One of the trickiest challenges when building an interactive typing game online is handling smartphone virtual keyboards (like Android Gboard or iOS Safari).
On desktop keyboards, pressing any key fires a standard KeyboardEvent with e.key.length === 1. On mobile devices, however, virtual keyboards use Input Method Editors (IME) with predictive composition, which often emit e.key = 'Unidentified' and keyCode: 229.
To support both seamlessly:
- We track keystrokes via direct input interception overlaying the paragraph stage.
- If a desktop single-character
keydownfires, sound effects and velocity update immediately. - If a mobile virtual keyboard inserts characters via
input/onChange, the engine compares the delta betweenuserInputandtargetTexton the fly, starting the wall-clock timer automatically.
You can try the live test on mobile or desktop at TypingGame.in Speed Test.
3. Real-Time 1v1 Multiplayer Racing
For the competitive arena at TypingGame.in/multiplayer, players can generate a 6-digit room code and race side-by-side.
Every keystroke emits a lightweight telemetry payload:
- Current character index
- Live WPM
- Accuracy percentage
- Progress completion ratio
A lightweight WebSocket relay synchronizes player cars on the track with interpolation, providing that nail-biting arcade racing sensation without heavy server overhead.
4. Lessons Learned & What's Next
- Pre-rendering matters: Static pre-rendering of 250 routes allowed the site to load in under 500ms with 0 Cumulative Layout Shift (CLS).
- Accessible inputs: Transparent focus interception provides a distraction-free experience while preserving native screen reader support.
Feel free to play a few rounds on TypingGame.in and share your fastest WPM score! If you have suggestions or questions about the architecture, let's discuss in the comments below!
Comments
Join the discussionNo comments yet. Be the first to comment.