How Runekeep turns typing practice into tower defence
Inside Runekeep's code: how targets lock, how difficulty ramps, why Letter Trial drills one row at a time, and how WPM and accuracy are counted.
Runekeep is a typing game dressed as tower defence: monsters carry a letter or an English word toward a tower, and typing it before they arrive makes the wizard on top fire a bolt. Everything here comes from the game's code; where we guess at reasons, we say so. You can try it here.
One key, one bolt
Monsters fly or walk along four lanes of a 384×216 pixel canvas. They queue up so labels never overlap, and a label becomes typeable only once it is fully on screen. The tower has five hearts; each minion that reaches it costs one. In Letter Trial, one correct key banishes a monster. In Word Quest, each correct letter knocks the monster back 2.5 pixels, and it falls when the word is done.
Choosing a target: locks and Backspace
Letter Trial has no lock: each key goes to the monster closest to the tower that carries that letter. The picker avoids letters already on screen and the letter it just used, so a key almost always matches a single minion.
Word Quest locks first. Your first letter locks onto the nearest monster whose word starts with it; after that, mistakes neither move the lock nor erase progress. The locked label gets a cyan frame and an underline under the next letter.
We read the lock as a guard against scattered progress: without it, a slip that matched another word's first letter would leave several words half-typed. The price is that a wrong lock needs an exit. Backspace releases it and resets that word to zero, so switching is never free. To make wrong locks rarer, the picker prefers words whose first letter is not already on screen.
Letter Trial: one row at a time
The five practice sets are Home row (A S D F G H J K L, the default), Top row, Bottom row, All letters and Mixed case (Shift). A standard touch-typing table gives every letter a finger and every finger a colour: purple pinky, blue ring, green middle, yellow index.
The code does not say why it splits by row, but within one row the fingers move the same way (barely on the home row, up for the top, down for the bottom), so you can learn which finger owns which key before rows mix. In Mixed case, each letter has an even chance of being uppercase, and the hint asks for Shift on the opposite hand, as standard technique teaches.
The picker also leans on your weak keys:
// Letters the player keeps missing come up more often.
function pickLetter(r) {
const pool = [...(LETTER_SETS[r.set] || LETTER_SETS.all)];
const live = new Set(r.enemies.filter((e) => !e.dead && !e.boss).map((e) => e.text.toLowerCase()));
let list = pool.filter((c) => !live.has(c) && c !== r.lastCh);
if (!list.length) list = pool;
const ws = list.map((c) => 1 + Math.min(3, (r.misses[c] || 0) * 0.5));
A letter's weight is 1 plus half its miss count, with the bonus capped at 3, so a key you keep missing appears up to four times as often. Misses include the key you should have pressed when you slipped and the letter on any monster that reached the tower, and they last the whole run.
Word Quest: 226 words with Chinese meanings
The list holds 226 words in three tiers: Apprentice, 3–4 letters (88); Adept, 5–6 (77); Archmage, 7 or more (61, up to nine). Most are fantasy or everyday words such as rune, potion and labyrinth. Each has a Traditional Chinese meaning, shown under the word when Show Chinese meanings is on (the default in the Chinese interface). The picker also skips the last 18 words it used.
How the pressure ramps
Speed and spawn rate come from four lines:
const ramp = (r) => 1 + 0.012 * r.waveKills + 0.15 * (r.wave - 1);
const baseSpeed = (r) => (r.mode === 'letters' ? 15 : [0, 10.5, 9.5, 8.6][r.tier]) * r.speedMul * ramp(r);
const spawnGap = (r) => (r.mode === 'letters' ? 1.55 : [0, 2.5, 2.9, 3.3][r.tier]) / Math.pow(r.speedMul, 0.85) / ramp(r);
const maxAlive = (r) => (r.mode === 'letters' ? 6 : 5);
- Letter monsters walk 15 pixels a second and arrive every 1.55 seconds. Word monsters walk 10.5, 9.5 or 8.6 by tier and arrive every 2.5, 2.9 or 3.3 seconds, so longer words come slower and sparser. At most six letter or five word monsters share the screen.
- Slow, Normal and Fast multiply speed by 0.6, 1 and 1.4. Because the spawn gap divides by the multiplier to the power 0.85, Slow cuts walking speed to 60% but the arrival rate only to about 65%.
- Each monster banished adds 1.2% to speed and spawn rate, and each new wave adds 15%. A wave is 30 monsters in Letter Trial and 16 in Word Quest.
There is no clock in these formulas, only kills and waves, so a slower typist also gets a slower ramp.
The meteor storm
Mana fills only from correct keys: 4 per key in Letter Trial (25 keys) and 1.6 per letter in Word Quest (63 letters). With a full bar, Space drops a meteor on every minion on screen and empties the bar.
Meteor kills score half points, add nothing to your combo and do not count as typing, so they cannot pad speed or accuracy. The dragon is only pushed back 30 pixels, and if you were locked onto its spell, that progress resets. It looks meant for buying time, not for replacing typing.
The dragon at the end of each wave
When a wave is cleared, Emberwing arrives and the music jumps from 88 to 126 beats per minute. It carries four spells: four groups of four letters from your set, or four different words from your tier.
It walks only 4.2 pixels a second, plus 12% per wave, but if it touches the tower the run is lost outright. Each finished spell pushes it back a little, and it summons flying minions unless two are already on screen. In Letter Trial, a key that matches both a minion and the dragon goes to the minion; a code comment explains, "they are the threat". Beating it earns 300 points times the wave number, and Next wave restores two hearts, up to five.
Feedback while you type
- Sound is synthesised live with Web Audio. A correct key is a short blip whose pitch climbs a step every six keys in a row; a wrong key is a low buzz; every ten in a row adds a three-note chime.
- A correct key sends a bolt arcing from the wizard's orb, turns typed letters gold and flashes the monster white. A wrong key throws grey-purple sparks off the orb and shakes the screen.
- The on-screen keyboard lights the next key in its finger colour, with a hint such as "F · Left index", and flashes pressed keys cyan or red.
- The combo multiplier is 1 + combo ÷ 30, capped at 3× from 60. A wrong key or a monster reaching the tower resets it.
What the results screen measures
- Word Quest shows words per minute: correct keystrokes ÷ 5 ÷ minutes, the usual five-characters-per-word convention. Letter Trial shows letters per minute.
- Accuracy is correct ÷ (correct + wrong), and a wrong key counts only when something was there to type. Time excludes pauses, and the figures carry across waves in one run.
- Keys to practise lists your three most-missed keys with counts and fingers, over a small keyboard heat map. It records the key you should have pressed, not the one you hit; we take that as a way to point at keys you have not learned yet.
- A won wave earns three stars for 96% accuracy with at least four hearts left, two for 88%, otherwise one. A loss suggests: "Try the Slow speed. Accuracy first; speed follows."
For beginners
- The title screen says "Rest both index fingers on the F and J bumps.", and the on-screen F and J keys show a bump.
- The defaults are Home row, Apprentice and Normal speed, with the finger guide on.
- With an input method such as Zhuyin active, the game reads physical key positions instead and says so.
- Held keys do not repeat, Mixed case warns about Caps Lock, and touch screens can use the on-screen keyboard. Switching tabs pauses the game; Esc pauses and resumes.