I'm developing an UWP app for XBOX using the WebView method on VS2022.
I'm using the addEventListener
method to listen for all the keyDown
events that are getting triggered when any button is pressed on the XBOX controller.
But the keydown events are not getting triggered at all when I launch the app and to access this keyDown events I need to click on the Controller X icon and close the menu bar after doing this the events are triggered properly.
JS Code Snippet:
document.addEventListener(
"keydown",
ev => {
if (ev.keyCode === 196) {
ev.preventDefault(); // I'm using this to prevent the default back functionality of xbox.
}
},
false
);
UWP Code Snippet:
public App()
{
this.InitializeComponent();
this.RequiresPointerMode = ApplicationRequiresPointerMode.WhenRequested; // used this method to remove the mouse mode on XBOX.
this.Suspending += OnSuspending;
}
Is there anyway that can be used to trigger the keyDown events when the app is launched.
Thanks in advance. Happy Coding!!!