0

Im trying to navigate between buttons with Keys(DPAD) so i need to listen for KeyEvents

I Solved it for Android i just don't know how to do it in IOS

public onButtonLoaded_1(args) {
    let btn = args.object as Button;
    let androidButton = btn.android as android.widget.Button

    androidButton.setOnKeyListener(new android.view.View.OnKeyListener({
        onKey: function (view, keyCode, keyEvent) {
          if (
            keyCode == android.view.KeyEvent.KEYCODE_DPAD_CENTER &&
            keyEvent.getAction() == android.view.KeyEvent.ACTION_DOWN
          ) {
            console.log("DPAD Center Pressed");
          }
            

            return false;
        }
    }))
 
  }

It does not work for Volmue Up and Down in Emulator i did not testet in a Device. ######################################################################

For IOS I have no Idea how to do it, i foud this maybe someone knows hot make it happen in IOS

https://developer.apple.com/library/archive/documentation/General/Conceptual/AppleTV_PG/DetectingButtonPressesandGestures.html

https://www.hackingwithswift.com/example-code/uikit/how-to-detect-keyboard-input-using-pressesbegan-and-pressesended

How to add detect button presses in tvOS?

How to handle Menu Button action in tvOS remote

How to detect a 'Click' gesture in SwiftUI tvOS

Swift Keyboard Keycodes

https://gist.github.com/swillits/df648e87016772c7f7e5dbed2b345066

4
  • Why are you trying to write native code? Why don't you use angular's key events such as (keydown)="onKeyDown($event)"? Commented Jan 3, 2022 at 14:19
  • ohhh, but do u catch ios keys can u show me or volume up down ? Commented Jan 3, 2022 at 15:57
  • Did you try logging the key events and checking their content for a 'keycode' property? Commented Jan 3, 2022 at 16:07
  • i just testet in androidtv emulator , i does not seem is working so, if someone knows how to do it with native code please help me :) Commented Jan 3, 2022 at 16:19

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.