Supporting Controllers in Web Apps (Amazon Fire TV)

Amazon Fire TV supports user input from the Amazon Fire TV remote, the Amazon Fire game controller, and other game controllers that support the Bluetooth HID gamepad profile. These controllers give users a means of navigating in your app and selecting items.

Using Input from the Amazon Fire TV Remote

Most Amazon Fire TV remote controls have these buttons. Some Fire TV remotes do not include the microphone or voice search buttons.

Remote control
Remote control

The remote for Fire TV Edition has some additional buttons — volume up/down, power, Netflix, Amazon Music, and Amazon Prime. However, these buttons can’t be mapped to events in third-party apps, so the buttons shown in the above Fire TV remote are effectively the same available buttons for Fire TV Edition’s remote, even if the remotes look a bit different.

To enable users to interact with your web app by using the remote, you need to capture the key events when users press one of the keys. Most key presses can be captured just as standard keyboard events in a browser.

For keycode mappings, see the following table. The Back, Home, Menu, and Voice Search buttons cannot be captured. For a workaround that allows customizing Back button behavior with HTML5 web apps, see the Fire TV Web Apps FAQ.

Amazon Fire TV Remote Button Key Code Standard Behavior
Select (D-Pad Center) 13 Selects the user interface item with the current focus.
Up (D-Pad) 38 Moves the focus upward in the user interface.
Down (D-Pad) 40 Moves the focus downward in the user interface.
Left (D-Pad) 37 Moves the focus left in the user interface.
Right (D-Pad) 39 Moves the focus right in the user interface.
Play/Pause 179 Controls media playback. Play/Pause is a toggle.
Rewind 227 Rewinds or skips backwards in media playback contexts.
Fast Forward 228 Fast Forwards or skips ahead in media playback contexts.
Back NA Navigates back in the history stack.

These key events are sent only to apps that are in focus.

Using Input from the Amazon Fire Game Controller

Developing for the Amazon Fire Game Controller is straightforward:

  • Amazon WebView supports the W3C standard Gamepad APIs.
  • The buttons on the Amazon Fire Game Controller map to the standard gamepad format.
  • In using the Gamepad APIs with the Amazon Fire Game Controller, the Back button is equivalent to Select on a standard controller, and the Menu button is equivalent to Start. If you do not use the Gamepad APIs, the buttons behave as Back and Menu buttons.

For more information on developing for the Standard Gamepad APIs, see Jumping the Hurdles with the Gamepad API.

If you choose not to use the Gamepad APIs, the buttons on the Amazon Fire Game Controller generally map to the same functions as on the Amazon Fire TV Remote (other than the B button).

The Amazon Fire TV (Gen 2) Game Controller has these buttons:

The Amazon Fire TV (1st Generation) Game Controller has these buttons:

The following table shows the key mappings.

Amazon Gamepad Controller Button Key Code Standard Behavior
Up (D-Pad/Joystick) 38 Move the focus upward in the user interface.
Down (D-Pad/Joystick) 40 Move the focus downward in the user interface.
Left (D-Pad/Joystick) 37 Move the focus left in the user interface.
Right (D-Pad/Joystick) 39 Move the focus right in the user interface.
A 13 Select the user interface item with the current focus.
B 8 None
X 13 Select the user interface item with the current focus.
Y 13 Select the user interface item with the current focus.
Back NA Navigates back in the history stack.

Play/Pause Media Button

A requirement for all media apps submitted for Amazon Fire TV is that they handle the media Play/Pause key events to control media playback. All Game applications must also handle the media Play/Pause key events to play or pause the game. The key code for the Play/Pause button is 179.