TV Remote events in WebView

Hello. WebView doesn’t seem to receive remote’s Menu button presses (allowSystemKeyEvents is set to true). Is this a deliberate choice or an accidental omission?

As a workaround, I’ve used useTVEventHandler:

useTVEventHandler((event) => {
	if (
		event.eventType === 'menu' &&
		(event.eventKeyAction === 0 || event.eventKeyAction === 1)
	) {
		webRef.current?.injectJavaScript(`
			(function (){
				const event = document.createEvent('Event');
				event.initEvent(${JSON.stringify(event.eventKeyAction ? 'keyup' : 'keydown')}, true, true);
				event.key = ${JSON.stringify('ContextMenu')};
				(document.activeElement || window).dispatchEvent(event);
			})();
		`);
	}
});

Somewhat relatedly, neither WebView nor useTVEventHandler seem to recognize some TV remote button presses sent via HDMI, for example red/green/yellow/blue buttons present on older remotes. WebView just doesn’t receive them, while useTVEventHandler receives {eventId: number, eventKeyAction: 0 | 1, eventType: 'unknown'}

Numpad presses are recognized via useTVEventHandler as eventType: 'num_{0...9}'

Hi @zemlanin,

Thank you for the detailed bug report on WebView Menu button handling.

Menu Button: This is a known limitation - allowSystemKeyEvents currently doesn’t pass Menu button events to WebView. Your workaround using useTVEventHandler + injectJavaScript is the recommended approach.

HDMI CEC Color Buttons: These legacy buttons (red/green/yellow/blue) have limited support as they’re not present on modern Fire TV remotes. The eventType: 'unknown' is expected for unsupported key codes.

Our team is investigating this issue and will provide an update as soon as we have more information.

Thanks for helping us improve the Vega platform.

Best regards,
Aishwarya

1 Like