I’m trying to detect when the Back key is long-pressed. However, using window.addEventListener("keydown", ...)
doesn’t work because the event only fires when the key is released, at the same time as the keyup
event. For other keys, the keydown
and keyup
events fire as expected.
Is there another way to specifically detect a long press of the Back key?
Please set the disableBackHistoryAPI property to true in the appinfo.json and try again. You can refer to Handling a back button event. Thank you.
disableBackHistoryAPI
is already set to true. I am able to detect if the Back key was pressed, but I cannot differentiate between single-press and long-press.
Sorry for the late reply. As you mentioned, the back key press event is sent when released. And this is the TV specification. Basically, long pressing the back key is designed to exit the app and take you to Home. Therefore, the app doesn’t need to check the press type. For your information, the default long press action for the back key is:
Magic Remote Control Unit: Exit to Home.
Conventional Remote Control Unit:
- webOS 25: Exit to Home.
- webOS 24 and earlier: None.
1 Like