// Keypad keys and how one press changes a field value. export type KeypadKey = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" | "clear" | "back"; /** Applies one key press to a field value. Digits stop at `max` characters. */ export function applyKey(value: string, key: KeypadKey, max = 64): string { if (key === "clear") return ""; if (key === "back") return value.slice(0, -1); return value.length >= max ? value : value + key; }