Handwriting input: one box for whole words
Write a capital letter, then write the next letter right on top of it. The widget figures out where each letter starts and ends, clears finished letters out of your way, and suggests matching words as you write. Everything runs locally in the browser.
Embed it on your site
Add one script tag and one placeholder element. The widget mounts automatically and copies recognized text into whatever data-target points to (updating the value and firing an input event on form fields, or setting text content on other elements).
Changing the character set or word list above updates this snippet automatically. By default it reads capital letters; use data-set="lowercase|digits|punctuation|all" or data-alphabet="ABC…" to change that. Without a custom list, it uses the 10,000 most common English words (adapted to the active character set). If you use digits or punctuation with no matching words, it switches to free mode and treats every character equally.
Custom word list
As you write, the recognizer matches against the start of every word in the list, preferring complete words when the strokes fit well. List order matters: put more common words near the top. Words are automatically adjusted to match the active character set (uppercased for capitals, lowercased for lowercase, or expanded with Capitalized and UPPERCASE variants for the All 75 set). Words containing characters outside the active set are ignored, and duplicates are removed.
Lists saved in this browser
List IDs and edit tokens are saved only in this browser's local storage. Keep your edit token somewhere safe if you want to update a list later — the server won't show it again.
| id | name | words | saved | |
|---|---|---|---|---|
| None yet | ||||
You can also set words from JavaScript with widget.setWords(['RED', 'GREEN', …]) or widget.loadList('ol_…'), or in HTML using data-words="RED GREEN BLUE" or data-words-src="words.txt". The editor uses POST /api/overlap/lists, GET /api/overlap/lists/:id, and PUT /api/overlap/lists/:id (with the edit token).
JavaScript API
const w = await MillirecOverlap.create('#box', {
words: ['APPLE', 'BANANA', …], // or wordsSrc: 'words.txt', or list: 'ol_a1b2c3d4' (a hosted list)
target: '#answer', // input element to fill automatically
onWord: ({ word, canvas }) => { … }, // fired when a word finishes (done, tap, or idleFinish)
})
w.getText() // finished words w.getLiveText() // finished words + current word
w.getCandidates() // [{word, score, complete, inList}], best first
w.getHandwriting() // canvas of the current word's strokes side by side (pass { scope: 'all' } for all words)
w.finishWord() // accept best guess w.selectWord('WORK') // re-split strokes to match a chosen word
w.setWords([…]) // swap the word list w.undo() w.clearWord() w.clear() w.destroy()
The container also dispatches bubbling CustomEvents: millirec-overlap:ready, :stroke (fires after each stroke with text, live, current, candidates, canvas), :change, :word (word, letters, canvas, inList, selected), :select, and :error.
| option / attribute | default | description |
|---|---|---|
words · list · wordsSrc | default list | Word list source (in priority order) |
target, targetMode | — / live | Element to mirror text into; set targetMode="words" for finished words only |
size | 240 | Drawing box size in CSS pixels |
layout | column | Use row to place text, handwriting preview, and suggestions beside the box |
chips · history | 6 · 1 | Number of suggestion chips · how many previous words' handwriting to keep visible |
idleFinish | 0 | Seconds of pause before auto-finishing the current word (0 = off) |
theme · hide · placeholder | auto | Color theme; UI parts to hide (text handwriting words buttons); empty-box prompt |
engine | — | Advanced recognizer settings, e.g. {"commitMargin": 6, "oovPen": 8} |
Customize the look with CSS variables on the element (--mo-ink --mo-bg --mo-line --mo-accent --mo-muted --mo-suspect --mo-chip --mo-radius) or Shadow DOM parts (::part(box), ::part(text), ::part(handwriting), ::part(words), ::part(chip), ::part(buttons)).
Self-hosting
Download millirec-overlap.zip — includes the widget, WebAssembly matcher, letter templates, default word list, and a demo page. Serve the unzipped folder over HTTP and it runs with zero external requests. (If you still want to use hosted lists, point it at your server with window.MILLIREC_OVERLAP = { apiBase: '…' }.)
| file | what it is | size |
|---|---|---|
millirec-overlap.min.js | Widget UI, recognizer logic, and matcher glue | 52 KB (20 KB gz) |
millirec.wasm | WebAssembly stroke matcher | 30 KB (14 KB gz) |
training.capitals.json | Full and partial capital-letter templates (other sets have their own files; training.json has all of them) | 91 KB (19 KB gz) |
words.json / words.js | Default 10,000-word English list | 103 KB (38 KB gz) |
How it works
Because strokes arrive in the order you draw them, every letter is a consecutive run of strokes. After each stroke, a dynamic programming pass tests possible letter boundaries using the point-cloud matcher — checking both complete letters and partial letters (so an unfinished E isn't prematurely read as an I plus a stray line) — while weighting choices against your word list. Once a letter clearly beats the alternatives, it gets cleared to make space for the next one. Tapping a suggestion re-runs the split with that word locked in. On one writer's held-out drills written into one box, this reads 96–98% of capital words correctly and clears five out of six letters on the very next stroke. See docs/overlap.md for the full technical notes and benchmarks.
Note: the built-in templates come from a single writer's handwriting, and the numbers above were measured on that writer. Other people's capitals are usually close enough, but unusual letter shapes may take a few more taps to correct.