API Reference

Complete documentation of all components, props, hooks, and utilities

VirtualKeyboard

The main keyboard component with extensive customization options.

Required Props

PropTypeDescription
focusedInputRefRefObject<HTMLInputElement | HTMLTextAreaElement>Ref to the currently focused input element
isInputFocusedbooleanWhether an input is currently focused

Layout & Type Props

PropTypeDefaultDescription
inputTypeHTMLInputTypeAttribute'text'HTML input type (affects layout and validation)
defaultLayout'letters' | 'symbols' | 'numbers''letters'Initial keyboard layout to display
customLayouts{ letters?: string[][], symbols?: string[][], numbers?: string[][] }undefinedOverride default keyboard layouts

Callback Props

PropTypeDescription
onChange(value: string) => voidCalled when input value changes
onEnterClick() => voidCalled when Enter key is pressed
validate(value: string) => booleanCustom validation function

Customization Props

PropTypeDefaultDescription
keyLabelsRecord<string, string>{}Custom labels for keys (e.g., { 'enter': 'Submit' })
hiddenKeysstring[][]Array of keys to hide from keyboard
disabledKeysstring[][]Array of keys to disable (grayed out)
renderKey(key: string, defaultRender: ReactNode) => ReactNodeundefinedCustom render function for individual keys
renderSpecialKey(type: string, defaultRender: ReactNode) => ReactNodeundefinedCustom render function for special keys

Behavior Props

PropTypeDefaultDescription
syncWithHardwareKeyboardbooleantrueEnable/disable hardware keyboard synchronization
continuousPressConfig{ initialDelay?: number, interval?: number }{ initialDelay: 500, interval: 50 }Configuration for hold-to-repeat behavior
scrollConfig{ enabled?: boolean, offset?: number }{ enabled: true }Auto-scroll configuration when keyboard appears

Theming Props

PropTypeDescription
classNamestringAdditional CSS class name
themeVirtualKeyboardThemeTheme configuration object (see Theme Type below)

GlobalVirtualKeyboard

Automatically shows keyboard when any input is focused.

PropTypeDefaultDescription
enabledbooleantrueEnable/disable the global keyboard
classNamestringundefinedCustom CSS class name
onVisibilityChange(visible: boolean) => voidundefinedCalled when keyboard visibility changes
onEnterClick() => voidundefinedCalled when Enter key is pressed
onChange(value: string) => voidundefinedCalled when input value changes

VirtualKeyboardTheme

Theme configuration object for customizing keyboard appearance.

PropertyTypeDescription
backgroundColorstringBackground color of keyboard container
keyColorstringDefault key background color
keyTextColorstringText color on keys
keyActiveColorstringKey color when pressed
keyHoverColorstringKey color on hover
activeStateColorstringColor for active states (e.g., Caps Lock on)
keyBorderRadiusstringBorder radius for keys
keyFontSizestringFont size for key labels
keyHeightstringHeight of keys

Utility Functions

Pure functions exported for advanced usage.

createCaretManager

function createCaretManager( getInputRef: () => HTMLInputElement | HTMLTextAreaElement | null ): { insertText: (text: string) => void; backspace: () => void; }

Creates a caret manager for manipulating text in input elements.

setupHardwareKeyboard

function setupHardwareKeyboard(handlers: { onBackspace: () => void; onEnter: () => void; onSpace: () => void; onCapsToggle: () => void; onKeyClick: (key: string) => void; }): () => void // Returns cleanup function

Sets up hardware keyboard event listeners. Returns cleanup function.

Hooks

React hooks for state management and effects.

useContinuousPress

function useContinuousPress( callback: () => void, options?: { enableContinuousPress?: boolean; delay?: number; interval?: number; } ): { handleMouseDown: () => void; handleMouseUp: () => void; handleMouseLeave: () => void; }

Implements hold-to-repeat functionality (e.g., for backspace key).

useKeyboardScroll

function useKeyboardScroll( keyboardRef: RefObject<HTMLElement> ): { scrollInput: (input: HTMLElement) => void; resetScroll: () => void; }

Manages scrolling input elements into view when keyboard appears.