The question of getting started with Android TV: why can't enter events be blocked in onKeyDown?

very novice is getting started, what Android TV, wants to do is to make sure that the confirmation button of the remote control has been pressed. However, it is found that all other keys can enter the onKeyDown event, except that the confirmation key will not enter the onKeyDown event. If there is no way, it can only be intercepted in dispatchKeyEvent.

 override fun dispatchKeyEvent(event: KeyEvent): Boolean {
        Log.d("dispatchKeyEvent", "dispatchKeyEvent(), action=" + event.action + " keycode=" + event.keyCode)
        return super.dispatchKeyEvent(event)
    }

    override fun onKeyDown(keyCode: Int, event: KeyEvent?): Boolean {
        when (keyCode) {
            KeyEvent.KEYCODE_DPAD_CENTER ->
                Toast.makeText(this, "", Toast.LENGTH_SHORT).show()

            KeyEvent.KEYCODE_DPAD_DOWN ->
                Toast.makeText(this, "", Toast.LENGTH_SHORT).show()

            KeyEvent.KEYCODE_DPAD_LEFT ->
                Toast.makeText(this, "", Toast.LENGTH_SHORT).show()

            KeyEvent.KEYCODE_DPAD_RIGHT ->
                Toast.makeText(this, "", Toast.LENGTH_SHORT).show()

            KeyEvent.KEYCODE_DPAD_UP ->
                Toast.makeText(this, "", Toast.LENGTH_SHORT).show()

            KeyEvent.KEYCODE_BACK ->
                Toast.makeText(this, "", Toast.LENGTH_SHORT).show()
        }
        return super.onKeyDown(keyCode, event)
    }
Mar.11,2021

since only the confirm key cannot capture, set it to default.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e48b5e-43992.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e48b5e-43992.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?