Synopsis
Boolean publishKeyboardMessage(Object data, [Array<String> instanceIds])
Parameters
The Object data parameter is the keyboard state payload sent to remote device(s). The data object has the following structure:
{"totalValue": <total_value>,
"keyCode": <key_code>,
"cursorPosition": <cursor_position>,
"isKeyboardOnScreen": <keyboard_on_screen>,
"modifiers":
{"control": <control_state>,
"shift": <shift_state>,
"alt": <alt_state>},
"key": <last_key>, "layoutType": <layout_type>}
The data object has the following properties:
totalValue – A String of the complete value of all keys typed on the keyboard onscreen.
keyCode – A special key code integer of the last key typed, including:
8913202733343536444546121144145cursorPosition – An integer representing the zero-based offset of the cursor into the total string.
isKeyboardOnScreen – A Boolean that is true if the keyboard is currently on the Connected TV display, and false otherwise. This is only sent by the Engine and ignored if received from the remote device.
modifiers.control – A Boolean that is true if the control key is pressed, and false otherwise.
modifiers.shift – A Boolean that is true if the shift key is pressed, and false otherwise.
modifiers.alt – A Boolean that is true if the alt key is pressed, and false otherwise.
key – The character of the last key pressed. If the last key pressed was not a character, then the value is null or an empty string. In this case, the keyCode property should be populated.
layoutType – An integer which is 0 for a QWERTY keyboard and 1 for a PIN-entry keyboard.
If the optional parameter instanceIds is specified,
the message should only be sent to the remote devices identified. No other devices receive the message. This parameter can
be a String for a single instanceId, an Array<String> of instanceIds or null.
If null, the message is sent to all connected remote devices that are subscribed to keyboard messages.
Returns
Returns true if sending the message is successful. Returns false otherwise.
Description
Helper method to publish a keyboard message. Send the keyboard state to subscribed (or identified) devices so they can update
their keyboard displays.
When the remote device's keyboard changes, the app gets a notification via the onKeyboardStateChanaged event callback.