Keyboard

An on-screen keyboard component for text input on TV interfaces with spatial navigation support.

Import

import { Keyboard } from '@smart-tv/ui';

Basic Usage

Create a basic on-screen keyboard for text input.

const [value, setValue] = useState('');
<Keyboard
focusKey="search-keyboard"
value={value}
onChange={setValue}
onSubmit={(text) => handleSearch(text)}
placeholder="Search for movies..."
/>

Keyboard Layouts

Switch between different keyboard layouts.

// QWERTY Layout (default)
<Keyboard
focusKey="qwerty-kb"
layout="qwerty"
value={value}
onChange={setValue}
/>
// ABC Layout
<Keyboard
focusKey="abc-kb"
layout="abc"
value={value}
onChange={setValue}
/>
// Numeric Layout
<Keyboard
focusKey="numeric-kb"
layout="numeric"
value={value}
onChange={setValue}
/>

With Auto-complete

Add autocomplete suggestions for faster text input.

const [value, setValue] = useState('');
const [suggestions, setSuggestions] = useState([]);
const handleChange = (text) => {
setValue(text);
// Fetch suggestions based on input
const matches = searchSuggestions(text);
setSuggestions(matches);
};
<Keyboard
focusKey="autocomplete-kb"
value={value}
onChange={handleChange}
suggestions={suggestions}
onSuggestionSelect={(suggestion) => setValue(suggestion)}
/>

Custom Theme

Customize the keyboard appearance with themes.

<Keyboard
focusKey="themed-kb"
value={value}
onChange={setValue}
theme={{
background: 'bg-gray-900',
key: 'bg-gray-800 text-white',
keyActive: 'bg-blue-600 scale-110',
keyHover: 'bg-gray-700'
}}
/>

Props

PropTypeDefaultDescription
focusKeystringrequiredUnique identifier
valuestring''Current input value
onChangefunction-Value change handler
onSubmitfunction-Submit handler
layoutstringqwertyKeyboard layout type
placeholderstring-Input placeholder text
suggestionsarray[]Autocomplete suggestions
themeobject-Custom theme configuration

Best Practices

  • Show the keyboard in a modal or drawer for better focus management
  • Provide autocomplete suggestions to reduce typing effort
  • Use appropriate layouts based on input type (numeric for numbers, etc.)
  • Make keys large enough for easy navigation with remote control
  • Display the current input value clearly above the keyboard
  • Provide clear visual feedback for key presses