top

Remote Control

This topic describes how your application can receive input from a remote control.

The remote control is the most common way for users to interact with the TV.

Figure 1. Basic remote control and Samsung Smart Remote

Figure 1. Basic remote control and Samsung Smart Remote


Samsung TVs can have 2 types of remote controls:

  • Basic remote control
    The basic remote control is a traditional remote control that has, for example, number keys and colored function keys.
  • Samsung Smart Remote
    The Samsung Smart Remote is only supported on Samsung UHD TVs.
    It has only the essential keys and some special function keys. The user can access additional virtual keys on the TV screen by clicking the “123” key.
    Figure 2. Samsung Smart Remote virtual keys on the TV screen

    Figure 2. Samsung Smart Remote virtual keys on the TV screen

Some remote control keys have different functions based on whether they are clicked or long-pressed:

  • On the basic remote control:

    Table 1. Basic remote control key functions
    Key Click Key Name Long Press Key Name
    “Rewind” MediaRewind MediaTrackPrevious
    “Fast Forward” MediaFastForward MediaTrackNext
    Note

    The "MediaTrackPrevious" and "MediaTrackNext" keys are not supported on the emulator.

  • On the Samsung Smart Remote:

    Table 2. Samsung Smart Remote key functions
    Key Click Key Name Long Press Key Name
    “Back/Exit” Back Exit

Prerequisites

To use the TVInputDevice API, the application has to request permission by adding the following privilege to the “config.xml” file:

<tizen:privilege name='http://tizen.org/privilege/tv.inputdevice'>
</tizen:privilege> 

Handling Key Events

To detect and handle remote control key clicks:

  1. To retrieve information about the remote control keys that the TV supports, use the getSupportedKeys() method:

    var value = tizen.tvinputdevice.getSupportedKeys();
    console.log(value); 
    

    The method returns the key name and keyCode value for each supported key.

  2. To register the key, add the registerKey() method to the onload event, with the key name as the parameter:

    tizen.tvinputdevice.registerKey('MediaPlayPause'); 
    tizen.tvinputdevice.registerKey('ColorF0Red'); 
    

    Since 2016 models, you can batch register keys using the registerKeyBatch() method, which can improve application launch time:

    tizen.tvinputdevice.registerKeyBatch(['VolumeUp', 'VolumeDown']); 
    
    Note

    The "ArrowLeft", "ArrowUp", "ArrowRight", "ArrowDown", "Enter", and "Back" key events are detected automatically, and do not require separate registration.

  3. To receive notifications when a remote control key is clicked, add a listener for the keydown event:

    <body ... onkeydown='handleKeydown(event);'> ... </body>
    

    or

    document.body.addEventListener('keydown', handleKeyDown);
    

    For more information on the keydown event, see the W3C Keyboard Event Types.

  4. Define the listener.
    The parameter of the handleKeyDown() method is the keyCode value for the clicked key.

    function handleKeydown(event) {
      switch (event.keyCode) {
        case tizen.tvinputdevice.getKey('MediaPlayPause').code: //10252
          // Something you want to do
        break;
    
        case tizen.tvinputdevice.getKey('ColorF0Red').code: //403
          // Something you want to do
        break;
      ...
    

Remote Control Key Codes

The following table lists the remote control key names and their corresponding keyCode values.

Table 3. Remote control key codes
Key Name keyCode Key Name keyCode Key Name keyCode
ArrowLeft 37 MediaPlayPause 10252 Menu 18
ArrowUp 38 MediaRewind 412 Tools 10135
ArrowRight 39 MediaFastForward 417 Info 457
ArrowDown 40 MediaPlay 415 Source 10072
Enter 13 MediaPause 19 Exit 10182
Back 10009 MediaStop 413
MediaRecord 416 Caption 10221
VolumeUp 447 MediaTrackPrevious 10232 E-Manual 10146
VolumeDown 448 MediaTrackNext 10233 3D 10199
VolumeMute 449 Extra 10253
ChannelUp 427 0 48 PictureSize 10140
ChannelDown 428 1 49 Soccer 10228
ChannelList 10073 2 50 Teletext 10200
3 51 MTS 10195
ColorF0Red 403 4 52 Search 10225
ColorF1Green 404 5 53 Guide 458
ColorF2Yellow 405 6 54
ColorF3Blue 406 7 55
8 56
9 57
Minus 189
PreviousChannel 10190