Word Typing Adventure
Word Typing Adventure – Free Vanilla JavaScript Typing Runner Game
Word Typing Adventure is a free, copy-paste ready typing game built with pure vanilla JavaScript,
HTML, and CSS — no frameworks, no libraries, no npm install. Players type
floating word bubbles that appear randomly across a grassy field to advance
a runner character (😄) toward a trophy goal (🏆). Each correctly typed word moves
the player 80px forward with a smooth transition: left 0.4s ease
CSS animation. A 22-word pool includes common English words perfect for
beginner typists and children: jump, run, fast, hero, win, type, code,
adventure, treasure, magic, dragon, castle, and more.
The game demonstrates core vanilla JavaScript concepts: setInterval for dynamic
word spawning every 2–4 seconds, input event listener for real-time
keystroke detection, Array.from(document.querySelectorAll()).find() for DOM
element matching, CSS class toggling for the .typing green highlight and
.correct flash feedback, setTimeout for delayed element removal,
and a simple win condition checking playerPosition >= 900. Words auto-expire
after 15 seconds if not typed. A perfect beginner-to-intermediate JavaScript learning project.
What's Included in the Download
- 22-word dynamic word pool
- Random word spawn (setInterval)
- Random position per word (DOM)
- Real-time input event listener
- Green highlight on partial match
- Correct word flash + removal
- Runner advances 80px per word
- CSS transition smooth movement
- Score counter (Words: N)
- 15-second word auto-expire
- Win state + trophy congratulations
- Input disabled on win
- Single self-contained HTML file
- CC BY 4.0 — free for commercial use
How the Real-Time Word Highlight Works
Every keypress fires the input event listener. It reads input.value
and searches all .word elements for one whose data-word matches the
typed text. If found, the .typing CSS class is added, turning the bubble
background: #90EE90 and applying transform: scale(1.2) for visual
feedback. On an exact match where the word exists on screen, the .correct
class fires (bright green), the element is removed after 400ms, playerPosition
increments by 80, and player.style.left updates — triggering the CSS transition.
How to Customize: Add Words, Change Difficulty
To add words: edit the wordsList array — push any new words.
For school vocabulary exercises, replace all words with subject-specific terms.
To change difficulty: lower the setInterval second argument (e.g. 1000)
to spawn words faster. Reduce playerPosition += 80 to require more words.
Increase const finishLine = 900 for a longer game. To add a timer countdown,
declare a seconds variable and decrement it with setInterval, displaying
in a UI element and triggering game-over when it reaches zero.
Best Use Cases
Word Typing Adventure is ideal for: school typing practice apps, kids coding clubs and hackathons, JavaScript beginner tutorials, teacher classroom typing games, vocabulary reinforcement tools, frontend bootcamp portfolio projects, and as a foundation for building more advanced games (add difficulty levels, high score localStorage, countdown timer, or categories like animals/countries/coding terms).
License
Released under Creative Commons Attribution 4.0 International (CC BY 4.0). Free for personal, educational, and commercial use with attribution to Coodeverse.
Source Code
<!DOCTYPE html>
<html lang="en">
<head> <meta charset="UTF-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0"/> <title>Word Typing Adventure</title> <style> body { margin: 0; height: 100vh; background: linear-gradient(to bottom, #87CEEB, #E0F7FA); font-family: 'Courier New', monospace; overflow: hidden; display: flex; flex-direction: column; align-items: center; } #game-container { position: relative; width: 1000px; height: 400px; background: linear-gradient(to bottom, #228B22 70%, #8B4513 100%); border: 4px solid #333; margin-top: 20px; overflow: hidden; box-shadow: 0 0 20px rgba(0,0,0,0.5); } #ground { position: absolute; bottom: 0; width: 100%; height: 80px; background: #8B4513; } #player { position: absolute; bottom: 80px; left: 50px; width: 50px; height: 70px; background: #FF4500; border-radius: 10px 10px 0 0; transition: left 0.4s ease; } #player::before { content: '😄'; position: absolute; top: 10px; left: 10px; font-size: 30px; } #goal { position: absolute; bottom: 80px; right: 50px; font-size: 60px; } .word { position: absolute; background: rgba(255,255,255,0.9); padding: 8px 15px; border-radius: 10px; font-weight: bold; color: #333; box-shadow: 0 4px 8px rgba(0,0,0,0.3); user-select: none; transition: all 0.3s; } .word.typing { background: #90EE90; transform: scale(1.2); } .word.correct { background: #32CD32; color: white; } #input { margin-top: 20px; padding: 15px; font-size: 24px; width: 400px; text-align: center; border: 3px solid #333; border-radius: 10px; outline: none; } #score { position: absolute; top: 20px; left: 20px; font-size: 24px; color: white; text-shadow: 2px 2px 4px #000; } #message { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); font-size: 60px; color: gold; text-shadow: 4px 4px 8px #000; display: none; pointer-events: none; } </style>
</head>
<body> <h1>Word Typing Adventure</h1> <div id="game-container"> <div id="score">Words: 0</div> <div id="player"></div> <div id="goal">🏆</div> <div id="ground"></div> <div id="message">You Win! Congratulations</div> </div> <input type="text" id="input" placeholder="Type the words here..." autofocus /> <script> const wordsList = [ "jump", "run", "fast", "hero", "win", "type", "code", "adventure", "treasure", "magic", "dragon", "castle", "forest", "river", "mountain", "brave", "quest", "power", "speed", "victory", "legend", "explore" ]; const gameContainer = document.getElementById('game-container'); const player = document.getElementById('player'); const input = document.getElementById('input'); const scoreDisplay = document.getElementById('score'); const message = document.getElementById('message'); let score = 0; let playerPosition = 50; const finishLine = 900; function createWord() { if (message.style.display === 'block') return; const word = wordsList[Math.floor(Math.random() * wordsList.length)]; const wordEl = document.createElement('div'); wordEl.classList.add('word'); wordEl.textContent = word; wordEl.style.top = Math.random() * 200 + 50 + 'px'; wordEl.style.left = Math.random() * 600 + 300 + 'px'; wordEl.dataset.word = word; gameContainer.appendChild(wordEl); setTimeout(() => { if (wordEl.parentNode) wordEl.remove(); }, 15000); } input.addEventListener('input', () => { const typed = input.value.trim().toLowerCase(); const activeWord = document.querySelector('.word.typing'); if (activeWord) activeWord.classList.remove('typing'); const matchingWord = Array.from(document.querySelectorAll('.word')) .find(el => el.dataset.word === typed); if (matchingWord) matchingWord.classList.add('typing'); if (typed && wordsList.includes(typed)) { const correctWord = Array.from(document.querySelectorAll('.word')) .find(el => el.dataset.word === typed); if (correctWord) { correctWord.classList.add('correct'); setTimeout(() => correctWord.remove(), 400); playerPosition += 80; player.style.left = playerPosition + 'px'; score++; scoreDisplay.textContent = `Words: ${score}`; input.value = ''; if (playerPosition >= finishLine) { message.style.display = 'block'; input.disabled = true; } } } }); setInterval(createWord, Math.random() * 2000 + 2000); createWord(); </script>
</body>
</html>
Frequently Asked Questions
Common questions about the free Word Typing Adventure vanilla JavaScript typing game.
Yes — 100% free under Creative Commons Attribution 4.0. No sign-up, no payment. Click Download Project and use it in personal, educational, or commercial projects with attribution to Coodeverse.
You need: (1) an input event listener reading input.value in real time; (2) word elements in the DOM as targets; (3) comparison logic matching typed text against displayed words; (4) a CSS class toggle for partial match highlight; (5) a correct-match handler removing the word, advancing the player, and updating the score. In this game, setInterval spawns new word divs every 2–4 seconds at random positions.
Every keypress fires the input event. The listener finds a .word element whose data-word attribute matches the typed value and adds the .typing CSS class — changing background to #90EE90 and applying transform: scale(1.2). On an exact match with the word on screen, .correct flashes it bright green, it's removed after 400ms, and the player advances.
The #player div uses position: absolute and transition: left 0.4s ease. On each correct word, JavaScript increments playerPosition += 80 and sets player.style.left = playerPosition + 'px'. The CSS transition animates the movement smoothly. The win check is playerPosition >= 900 (the finishLine constant).
Yes. The 22 words (jump, run, fast, hero, dragon, castle, forest, etc.) are short, common, and age-appropriate. The visual runner and trophy goal provide clear motivation. The green highlight gives instant positive reinforcement. It works in any browser with no installation. Teachers can replace the wordsList array with vocabulary for any subject.
Edit the wordsList array to add or swap words. Lower the setInterval delay for faster spawning (harder). Reduce playerPosition += 80 to require more words to win. Increase const finishLine = 900 for a longer game. Add a countdown timer with another setInterval decrementing a seconds variable to add time pressure.
Browse the full collection at coodeverse.com/projects — VORTEX Interactive Canvas (800 physics particles), Particle Fireworks, Cosmos Star Animation, NEXUS 3D Pure CSS, Holographic Login and more. All 100% free with complete HTML CSS JavaScript source code.