How I Built an Open Online Typing Game Platform with Real-Time 1v1 Multiplayer in React
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 (https://typinggame.in) — an interactive, completely free online typing
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 (https://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.
- 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:
Gross WPM = (Total Characters Typed / 5) / Time Elapsed in Minutes
Net WPM = max(0, (Correct Characters / 5) / Time Elapsed in Minutes)
Accuracy % = (Correct Characters / Total Characters Typed) * 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.
- Dual-Engine Architecture: Desktop Keyboard vs. Mobile Virtual Keyboards
One of the trickiest challenges when building an interactive typing game online (https://typinggame.in/) 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 keydown fires, sound effects and velocity update immediately.
- If a mobile virtual keyboard inserts characters via input / onChange, the engine compares the delta between userInput and targetText on the fly, starting the wall-clock timer automatically.
You can try the live test on mobile or desktop at TypingGame.in Speed Test (https://typinggame.in/typing-test)
- 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.
- 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 (https://typinggame.in) and share your fastest WPM score! If you have suggestions or questions about the architecture, let's discuss in the comments below!
Originally published by Dev.to WebDev. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.