Skip to content

Text input ​

tv.text types into the focused text field of an Apple TV, such as a search field or a sign-in form.

ts
tv.text.on('change', state => {
    if (state.active) {
        console.log('a keyboard is up', state.secure ? '(password)' : '', state.text);
    }
});

await tv.text.set('The Bear');
await tv.text.append(' season 2');
await tv.text.clear();
MethodMeaning
set(text)Replaces the text of the focused field
append(text)Adds text at the end
clear()Empties the field

Which protocol types ​

Companion Link goes first. Without it the text goes through the remote text input session over AirPlay. The state follows the same protocol. The methods throw UnavailableError only when both protocols are down.

State ​

text.state is a TextState:

FieldMeaning
activeWhether a text field has focus
textThe current text; always empty over AirPlay
secureWhether the field is a password field
keyboardTypeThe keyboard type the field asks for
autocorrection, autocapitalizationThe traits of the field

change fires when a keyboard appears or goes away, and when Companion Link reports a new text. While Companion Link is down, the AirPlay keyboard messages fire it.

CoreWire is released under the MIT license.