NumberKeyboard
A mobile numeric-input helper for codes, amounts and license plates — cases that need only digits and a few letters. The component has no inner input: key results are exposed through the value attribute and the oas-input / oas-delete / oas-done events for the host to write into its own control.
Basic usage
Tap digit keys to append; value is written back to the host attribute. Delete removes the last character, Done dispatches oas-done.
Default numeric keyboard (maxlength=6)
value: (empty)
Wired to an input: write the value back on events
Randomized order (random)
With random the digit order is shuffled (secure keypad scenarios); randomize() reshuffles programmatically (e.g. on every focus).
random + reshuffle
License-plate layout (layout="plate")
layout="plate" switches to a plate keyboard: province abbreviations (the “Province” key opens the panel) + letters (A–Z without I / O) + digits.
plate
value: (empty)
Disabled and readonly
disabled / readonly
disabled: every key is disabled and no events are dispatchedreadonly: keys stay focusable (screen-reader friendly) but the value cannot change;oas-donestill fires (readonly is not “cannot submit”)
Long-press repeat delete (on by default)
Hold the delete key for 400ms and repeat-deleting starts: the interval begins at 300ms, decreases by 50ms each fire and bottoms out at 150ms — fixing several wrong digits no longer means tap-tap-tap (an established convention of keyboard apps, hence on by default). pointerup, moving off the key or gesture cancellation stops it; long-press only reacts to the primary button (right / middle button presses never start it); the delete key suppresses its context menu while held (a popping menu would interrupt the repeat), other keys are unaffected. Long-press and single taps do not interfere: the trailing click after a long-press release never deletes twice. Hosts needing strictly single-shot deletes (per-cell verified OTP inputs and the like) add no-repeat-delete. The physical Backspace key is untouched (its repeat comes from the OS key-repeat naturally).
no-repeat-delete: strictly single-shot (repeat disabled)
value: 123 (holding delete removes one digit)
Events and physical keyboard
While focus is inside the component, a physical keyboard works too: digits (plus letters in plate layout) and Backspace. Keys are native <button> elements, so Tab / Enter / Space work.
oas-input / oas-delete / oas-done
Waiting for input…
| Event | When | detail |
|---|---|---|
oas-input | A character is appended | { value, key } |
oas-delete | The last character is removed (not emitted when empty) | { value } |
oas-done | The done key is pressed | { value } |
Extra keys (extra-key)
extra-key attaches extra keys to the right of the 0 key on the bottom row of the digit area (grid column 3, next to the delete/done keys in column 4; an ID-card "X" key and the like): a single character or a JSON string array (at most 2; extras beyond that are truncated with a warning); the 0 key narrows automatically to make room. Extra characters join the physical-keyboard whitelist too (what is on screen can be typed):
ID-card X key
Click X or a digit key to see the value.
API
oas-number-keyboard
Attributes
| Attribute | Description | Type | Default |
|---|---|---|---|
disabled | Disabled: all keys disabled and no events are dispatched | boolean | — |
extra-key | Extra keys attached to the right side of the digit area (an ID-card X key and the like) — a single character or a JSON string array (at most 2, extras truncated with a devWarn); the 0 key narrows automatically; extra characters join the physical-keyboard whitelist | — | — |
layout | Keyboard layout: number (default) / plate (license plate: province + letters + digits) | string | number |
maxlength | Max length in characters (province abbreviations count as one); 0 or absent = unlimited | string | 0 |
no-repeat-delete | Disables long-press repeat delete on the delete key (on by default: hold 400ms to start repeating, interval 300ms decreasing to 150ms; pointerup / leaving / cancelling stops it) — turn off for strictly single-shot deletes (per-cell verified OTP inputs); physical Backspace is unaffected | boolean | — |
random | Shuffle the digit key order (secure keypad); reorders when toggled | boolean | — |
readonly | Readonly: keys stay focusable but the value is locked; oas-done still fires | boolean | — |
value | Current value (controlled): keys write back to this attribute and host writes apply immediately | — | — |
Methods
| Method | Signature | Description |
|---|---|---|
randomize | randomize(): void | Reshuffle the digit key order (secure keypad refresh) |
Events
| Event | Description |
|---|---|
oas-delete | The last character is removed (not emitted when empty), detail: { value } |
oas-done | The done key is pressed, detail: { value } |
oas-input | A character is appended, detail: { value, key } |