2 years ago

#5780

test-img

Edin.A

How to listen for Button KeyPresses in Android/IOS for Nativescript/Angular

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

nativescript

angular2-nativescript

nativescript-angular

nativescript-vue

0 Answers

Your Answer

Accepted video resources