Not receiving key down events for Back Button

:warning: Before you continue


Before submitting a bug report, please review our troubleshooting documentation at https://developer.amazon.com/docs/kepler-tv/troubleshoot-overview.html.

If you still want to file a bug report, please make sure to fill in all the details below and provide the necessary information.

NOTE: PLEASE ONLY REPORT A SINGLE BUG USING THIS TEMPLATE.
If you’re experiencing multiple issues, please file a separate report for each.


:backhand_index_pointing_right: Bug Description


1. Summary

When using a useTVEventHandler to detect long pressing with the back button, key events are not received until the key is released, at which point the key down and key up events are received at the same time.

App Name:
App Link on Amazon Appstore (found through Developer Console → Actions column in App List → View on Amazon.com):

Bug Severity
Select one that applies

  • Impacts operation of app
  • :check_mark:Blocks current development
  • Improvement suggestion
  • Issue with documentation (If selected, please share the doc link and describe the issue)
  • Other

2. Steps to Reproduce

Hold down the back button for at least 1 second, observe logs

 const longPressTimerRef = useRef<NodeJS.Timeout>()

  const handleLongBackPress = useCallback((evt: HWEvent) => {
    if (evt.eventType !== 'back') {
      return
    }

    if (evt.eventKeyAction === 0 && longPressTimerRef.current === undefined) {
      console.log('key down')
      longPressTimerRef.current = setTimeout(() => {
        // completion logic here
        console.log('long press completed')
      }, 800)
    } else if (evt.eventKeyAction === 1) {
      console.log('key up')
      clearTimeout(longPressTimerRef.current)
      longPressTimerRef.current = undefined
    }
  }, [])

  useEffect(() => clearTimeout(longPressTimerRef.current), [])

useTVEventHandler(handleLongBackPress)

3. Observed Behavior

Explain what actually happened, noting any discrepancies or malfunctions.

When button is pressed down, nothing happens.
When button is released, "key down" and "key up" log simultaneously.
"long press completed" never logs

4. Expected Behavior

Describe what you expected the SDK to do under normal operation.

When button is pressed down, "key down" logs.
After 800ms, "long press completed" logs.
When button is released, "key up" logs.

4.a Possible Root Cause & Temporary Workaround

Fill out anything you have tried. If you don’t know, N/A is acceptable

I tried using the menu button instead of the back button, the code works with the menu button.

5. Logs or crash report

(Please make sure to provide relevant logs as attachment and share VPKG file with your Amazon contact)

For crash issues, please refer this guide for faster troubleshooting: https://developer.amazon.com/docs/kepler-tv/detect-crash.html.

  • App/Device Logs

  • Crash Logs

  • Crash Report

  • For issues with Kepler Studio Extension, please share log files from below folders:

     ~/.vscode/extensions/amazon.kepler-extension-<version>/ExtensionLogs
     ~/.vscode/extensions/amazon.kepler-ui-extension-<version>/ExtensionLogs
    

6. Environment

Please fill out the fields related to your bug below:

  • SDK Version: 0.20.3207

  • App State: foreground

  • OS Information
    Please ssh into the device via kepler exec vda shelland copy the output from cat /etc/os-releaseinto the answer section below. Note, if you don’t have a simulator running or device attached kepler exec vda shell will respond with vda: no devices/emulators found

    sh(com.amazon.dev.shell):/$ cat /etc/os-release
    NAME="OS"
    OE_VERSION="4.0.0"
    OS_MAJOR_VERSION="1"
    OS_MINOR_VERSION="1"
    RELEASE_ID="2"
    OS_VERSION="1.1"
    BRANCH_CODE="VegaMainlineTvIntegration"
    BUILD_DESC="OS 1.1 (VegaMainlineTvIntegration/4418)"
    BUILD_FINGERPRINT="4.0.155683.0(3072cab629675a74)/4418N:user-external/release-keys"
    BUILD_VARIANT="user-external"
    BUILD_TAGS="release-keys"
    BUILD_DATE="Wed Sep 03 05:40:19 UTC 2025"
    BUILD_TIMESTAMP="1756878019"
    VERSION_NUMBER="201010441850"
    

Hi @anthony3662
Thank you for sharing this with us. We are looking into this and will get back to you soon.
Warm regards,
Ivy

Closing topic as issue is fixed/resolved.