Skip to main content

input

The sos.input API groups together all input-related functionality, such as remote control key events. With this API, you can listen to key events from the remote control and handle them in your application.

Methods

onKeyUp()

The onKeyUp method sets up a listeners, which is called on every keystroke of the remote controller. For the specific logic of an application (games for example), binding the remote control inputs can be helpful. Only a subset of all remote control keys is supported on the specific device. Only numerical digits are guaranteed to be supported.

note

This feature must be tested by users on real devices.

onKeyUp(listener: (event: IKeyUpEvent) => void): void;

Params

NameTypeRequiredDescription
listener(event: IKeyUpEvent) => void
Yes
The listener function that will be called on every key up event.

Return value

Resolves when the listener is successfully set up.

Possible errors

  • If listener is not valid function.
  • If listener is unregistered.

removeEventListener()

The removeEventListener() method removes all event listeners for a specific event (only keyup is supported).

removeEventListener(event: 'keyup', listener: (...args: any[]) => void): void;

Params

NameTypeRequiredDescription
event"keyup"
Yes
The name of the event to remove the listener for. Currently, only keyup is supported.
listener(...args: any[]) => void
Yes
The listener function to remove.

Return value

Resolves when the listener is successfully removed.

removeEventListeners()

The removeEventListeners() method removes all event listeners bind on sos.input object.

removeEventListeners(): void;

API Example

import { sos } from '@signageos/front-applet';

void sos.onReady(async () => {
sos.input.onKeyUp((keyUpEvent) => {
console.log(`Pressed: ${keyUpEvent.keyCode} (${keyUpEvent.keyName})`);
});
});