Built with millirec
The handwritten games on digitizer.fun — crosswords, Handle, hangman, and quizzes — along with handwritten Sudoku and chess all run on the same browser recognizers you can drop into your own site. Here's how each one uses millirec.
npm install millirec
Live sites using millirec
- Single-character recognition (one letter per box): Crossword, Handle, and Hangman on digitizer.fun
- Handwritten autocomplete (write whole words in one box): Border Quiz and Quizzes
- Six-character room codes (write a code to join a game): Emoji code for two, Free Dots, and Drone Spy for two
- Drawn blog reactions: under every post on blog.triplelog.com
Capital letters in boxes
All of the word games share a single instance of char-cnn (98.5% accuracy on held-out capital letters), with
one box per letter. Scramble passes the only option so a box can only match letters from the
puzzle. Handle and Hangman use the top three guesses and their probabilities instead of just the #1
guess, so an ambiguous letter splits its weight.
import { MillirecCharCnn } from 'millirec/char-cnn'
// uses the 'accurate' option by default
const rec = await MillirecCharCnn.create()
rec.attach(box) // or pass strokes to recognize()
// [{ char: 'R', prob: 0.91 }, …]
const top3 = await rec.recognize(strokes)
// restrict guesses to valid letters for this box
const fit = await rec.recognize(strokes,
{ only: 'CRANE' })
Digits limited to valid values
Handwritten Sudoku uses char-lite's digits set. For a 6×6 grid, only digits 1–6 are allowed, so any result outside that range gets filtered out rather than placing an invalid number in the square.
import { MillirecCharLite, loadSet } from 'millirec'
const training = await loadSet('digits')
const rec =
await MillirecCharLite.create({ training })
const allowed = new Set('123456') // for a 6×6 grid
const read = async (strokes) =>
((await rec.recognize(strokes)) || [])
.filter((r) => allowed.has(r.char))
Custom symbols drawn by players
In Emoji Code, players draw their own shorthand for each emoji. Because
char-lite accepts any string as a class name, it learns custom shapes from just a couple of
drawings. Built-in default signs let you play right away, and your own drawings replace them as you add them.
// build one class per emoji from the player's drawings
const sample = (d) =>
MillirecCharLite.strokesToSample(d)
const training = Object.fromEntries(signs.map(
({ emoji, drawings }) =>
[emoji, drawings.map(sample)]))
const rec =
await MillirecCharLite.create({ training })
// [{ char: '🍀', prob: … }, …]
await rec.recognize(strokes)
Adapting to a player's handwriting
Players can save letters and digits they've written to improve recognition for their own handwriting.
For letters, personalize() gently adjusts char-cnn's final layer toward the
player's examples, anchored to the base model: a few samples nudge a letter, and many take it over. For digits, the player's samples are added to the
template set and replace the defaults once there are at least three.
// letters: adapt the neural net to this user
await letters.personalize(
{ A: [a1, a2, a3], R: [r1, r2] })
// digits: replace the default 7s with the user's own
const mine = MillirecCharLite.withSamples(digitsSet,
{ 7: [s1, s2, s3] }, { replace: true })
const digits =
await MillirecCharLite.create({ training: mine })
Whole words in a single box
Quizzes and handwritten chess use the handwriting input, where you write
letters on top of each other in one box and match against a word list (97.8% word accuracy on capitals).
Quizzes pass the list of possible answers. Chess updates the list after every turn to only allow legal moves,
so "Nf3" is only recognized when it's actually a legal move. The chess position builder uses
char-lite to read one piece letter per square.
<script src="https://cdn.jsdelivr.net/npm/millirec@0.2.0/dist/overlap/millirec-overlap.min.js"></script>
const box = await MillirecOverlap.create(el,
{ set: 'capitals', words: quiz.answers })
// chess: update to only the legal moves in this position
box.setWords(legalMoves(position))
Handwritten room codes
Multiplayer rooms on digitizer.fun use 6-character codes built from an alphabet without look-alike
characters (no O/0, l/1, or S/5).
Each box is read by char-lite trained only on that reduced alphabet, ignoring any character outside it.
import { MillirecCharLite } from 'millirec'
// templates limited to the code alphabet
const rec = await MillirecCharLite.create(
{ training: codeTraining })
const ok = new Set(alphabet)
const read = async (strokes) =>
((await rec.recognize(strokes)) || [])
.filter((r) => ok.has(r.char))
Drawn blog reactions
Readers on blog.triplelog.com can draw a heart, checkmark, or star at the bottom of a post instead of clicking a button. Recognition runs in the browser, and the widgets server verifies each drawing before displaying it on the wall.
<script async
src="https://YOUR-SERVER/embed/millirec-widget.js">
</script>
<div data-millirec="reactions"
data-widget="default"></div>
Try it in your own project
Everything shown here is powered by the millirec package — MIT licensed, zero dependencies, and 100% client-side. Start with the ready-made letter and digit models, train your own symbols, or embed the handwriting input.