Android TV D-Pad Functions
WebToNative's Smart TV Support add-on forwards every remote button press into your website as a JavaScript function call, so your site can react to it
When your app runs on an Android TV device, users navigate with a remote control (D-Pad) instead of touch.
Unlike the other bridges in these docs, this is not something your website calls it's a contract in the other direction: your website defines a global function, and the native app calls it whenever the user presses a remote key.
You'll need to import the javascript file in your website before starting from this link.
Platform support: Android only. This add-on has no iOS/tvOS equivalent
handleKeyEventis never called on iOS.
How It Works
Enable Smart TV Support in the WebToNative dashboard (see Setup below).
On your website, define a global
window.handleKeyEvent(key)function.When the app is running on a device the SDK detects as Android TV, every remote button press is checked against
typeof handleKeyEvent === 'function'. If your function exists, it's called with a string identifying the key (see Key Values below).
Setting Up Smart TV Support
Go to your WebToNative dashboard → Add-ons → Smart TV Support and enable it.
No credentials are required — once enabled, the behaviour described on this page is active automatically whenever the app is running on a device detected as Android TV.
Defining handleKeyEvent
Define this function anywhere on your page, before the user starts interacting with the remote (e.g. on page load):
Parameters passed to your function:
Your function has no meaningful return value — nothing reads it.
Key Values
UP
D-Pad Up
Always also moves DOM focus upward, in addition to calling handleKeyEvent.
DOWN
D-Pad Down
Always also moves DOM focus downward, in addition to calling handleKeyEvent.
LEFT
D-Pad Left
Always also moves DOM focus left, in addition to calling handleKeyEvent.
RIGHT
D-Pad Right
Always also moves DOM focus right, in addition to calling handleKeyEvent.
CENTER
D-Pad Center / Select
Also re-dispatched to the WebView for native focus handling, see the warning above.
HOME
Home
Also re-dispatched to the WebView.
MENU
Menu
Also re-dispatched to the WebView.
ENTER
Enter
Also re-dispatched to the WebView.
INFO
Info
Also re-dispatched to the WebView.
PLAY
Media Play/Pause (while paused)
Not re-dispatched your website is fully responsible for handling it. If handleKeyEvent isn't defined, the user sees a "Media Player not working" toast and nothing happens.
PAUSE
Media Play/Pause (while playing)
Same as PLAY not re-dispatched, fully your responsibility.
STOP
Media Stop
Same as PLAY not re-dispatched, fully your responsibility.
NEXT
Media Next Track
Not re-dispatched. No fallback toast if undefined it's simply a no-op.
PREVIOUS
Media Previous Track
Not re-dispatched. No fallback toast if undefined it's simply a no-op.
Keys That Never Reach handleKeyEvent
Back
Handled entirely natively as the app's back-navigation action. Never forwarded to JavaScript.
Voice/Assistant button
Natively launches Google Assistant. Never forwarded to JavaScript.
Implementation Checklist
WebToNative Dashboard
Your Website
Frequently Asked Questions
Last updated