key-layout
The pure keyboard model: which keys exist in each mode, what a long-press offers,
and where every key sits. No DOM, no Babylon — just data and geometry, so the layout
is unit-testable and the view is a straight paint of keyRects().
A software keyboard isn't optional garnish here. In a headset there is no other way
to type: the OS keyboard isn't reliably available to a WebXR session, and a DOM
<input> doesn't exist inside an immersive scene. Same code serves the flat overlay.
Modes
| Mode | For |
|---|---|
alpha |
letters, with shift |
alphanumeric |
letters plus a digit row |
symbols |
punctuation and symbols |
numpad |
digits in a 3×4 block — quantities, seeds, coordinates |
Long-press accents
Holding a letter offers its accented forms (o → ò ó ô ö õ ø œ), the phone
convention — and the reason the press-hold-drag gesture exists at all. Keeping the map
here (rather than in the view) means the popup's contents are testable and the same in
both presentations.
import { keyLayout, accentsFor, keyRects } from 'tosijs-3d'
const rows = keyLayout('alpha', false)
accentsFor('o') // ['ò','ó','ô','ö','õ','ø','œ']
keyRects(rows, { width: 320, keyHeight: 40, gap: 4 }) // → [{key,x,y,width,height}]