Skip to content

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

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 dispatched
  • readonly: keys stay focusable (screen-reader friendly) but the value cannot change; oas-done still 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…

EventWhendetail
oas-inputA character is appended{ value, key }
oas-deleteThe last character is removed (not emitted when empty){ value }
oas-doneThe 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 ​

AttributeDescriptionTypeDefault
disabledDisabled: all keys disabled and no events are dispatchedboolean—
extra-keyExtra 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——
layoutKeyboard layout: number (default) / plate (license plate: province + letters + digits)stringnumber
maxlengthMax length in characters (province abbreviations count as one); 0 or absent = unlimitedstring0
no-repeat-deleteDisables 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 unaffectedboolean—
randomShuffle the digit key order (secure keypad); reorders when toggledboolean—
readonlyReadonly: keys stay focusable but the value is locked; oas-done still firesboolean—
valueCurrent value (controlled): keys write back to this attribute and host writes apply immediately——

Methods ​

MethodSignatureDescription
randomizerandomize(): voidReshuffle the digit key order (secure keypad refresh)

Events ​

EventDescription
oas-deleteThe last character is removed (not emitted when empty), detail: { value }
oas-doneThe done key is pressed, detail: { value }
oas-inputA character is appended, detail: { value, key }

Released under the MIT OR Apache-2.0 License.