Options

You can customize the Keyboard by passing the following options to it. Click on any option to see more details and examples.

Layout & Display

OptionDescription
layoutModify the keyboard layout.
layoutNameSpecifies which layout should be used.
displayReplaces variable buttons (such as {bksp}) with a human-friendly name (e.g.: backspace).
mergeDisplayBy default, when you set the display property, you replace the default one. This setting merges them instead.
excludeFromLayoutExclude buttons from layout.

Styling & Theming

OptionDescription
themeA prop to add your own css classes to the keyboard wrapper. You can add multiple classes separated by a space.
buttonThemeA prop to add your own css classes to one or several buttons.
buttonAttributesA prop to add your own attributes to one or several buttons.
useButtonTagRender buttons as a button element instead of a div element.
baseClassSet a custom base class for the keyboard wrapper.

Input Handling

OptionDescription
inputNameAllows you to use a single simple-keyboard instance for several inputs.
maxLengthRestrains all of simple-keyboard inputs to a certain length. This should be used in addition to the input element's maxlength attribute.
inputPatternRestrains input(s) change to the defined regular expression pattern.
newLineOnEnterSpecifies whether clicking the "ENTER" button will input a newline (\n) or not.
tabCharOnTabSpecifies whether clicking the "TAB" button will input a tab character (\t) or not.
syncInstanceInputsWhen set to true, this option synchronizes the internal input of every simple-keyboard instance.

Caret & Text Positioning

OptionDescription
disableCaretPositioningA prop to ensure characters are always be added/removed at the end of the string.
updateCaretOnSelectionChangeUpdates caret when selectionchange event is fired.

Mouse & Touch Events

OptionDescription
useMouseEventsOpt out of PointerEvents handling, falling back to the prior mouse event logic.
useTouchEventsInstructs simple-keyboard to use touch events instead of click events.
autoUseTouchEventsEnable useTouchEvents automatically when touch device is detected.
clickOnMouseDownWhen useMouseEvents is enabled, this option allows you to trigger a button click event on mousedown.
preventMouseDownDefaultCalling preventDefault for the mousedown events keeps the focus on the input.
preventMouseUpDefaultCalling preventDefault for the mouseup events.
stopMouseDownPropagationStops pointer down events on simple-keyboard buttons from bubbling to parent elements.
stopMouseUpPropagationStops pointer up events on simple-keyboard buttons from bubbling to parent elements.
disableButtonHoldDisable button hold action.

Physical Keyboard Integration

OptionDescription
physicalKeyboardHighlightEnable highlighting of keys pressed on physical keyboard.
physicalKeyboardHighlightPressCalls handler for a button highlighted by physicalKeyboardHighlight. In other words, this calls keyboard.handleButtonClicked(buttonName) on the highlighted button.
physicalKeyboardHighlightPressUseClickTrigger click on a button's element when using physicalKeyboardHighlightPress. In other words, this calls button.click() on the highlighted button.
physicalKeyboardHighlightPressUsePointerEventsWhether physicalKeyboardHighlightPress should use pointer events to trigger buttons.
physicalKeyboardHighlightPreventDefaultWhether physicalKeyboardHighlight should use preventDefault to disable default browser actions.
physicalKeyboardHighlightTextColorDefine the text color that the physical keyboard highlighted key should have.
physicalKeyboardHighlightBgColorDefine the background color that the physical keyboard highlighted key should have.

Layout Candidates (IME Support)

OptionDescription
enableLayoutCandidatesEnable input method editor candidate list support.
layoutCandidatesCharacter suggestions to be shown on certain key presses.
layoutCandidatesPageSizeDetermines size of layout candidate list.
layoutCandidatesCaseSensitiveMatchDetermines whether layout candidate match should be case sensitive.
disableCandidateNormalizationDisables the automatic normalization for selected layout candidates.
enableLayoutCandidatesKeyPressEnables onKeyPress triggering for layoutCandidate items.

Localization

OptionDescription
rtlAdds unicode right-to-left control characters to input return values.

Event Callbacks

OptionDescription
onKeyPressRetrieves the pressed key.
onChangeRetrieves the current input.
onChangeAllRetrieves all inputs.
onKeyReleasedRetrieves the released key.
onRenderExecutes the callback function every time simple-keyboard is rendered (e.g: when you change layouts).
onInitExecutes the callback function once simple-keyboard is rendered for the first time (on initialization).
beforeInputUpdateExecutes the callback function before an input is about to be updated.

Debug & Development

OptionDescription
debugRuns a console.log every time a key is pressed. Displays the buttons pressed and the current input.