1

I have an xbox one app that has a webview containing a javascript app.

In my React app I have something like this:

navigator.gamepadInputEmulation = 'gamepad';

window.addEventListener('onkeydown', function(event) {
  if (event.keyCode === 196) {
    event.stopImmediatePropagation();
    // custom back button logic
  }
});

The custom back button logic runs but then the default controller back button logic also runs even with event.stopImmediatePropagation(); Is there any fix for this?

If I set navigator.gamepadInputEmulation = 'keyboard'; this issue goes away but then all the controller input events run twice.

Jacob Relkin
  • 161,348
  • 33
  • 346
  • 320
user1572796
  • 1,057
  • 2
  • 21
  • 46

1 Answers1

0

Here is a quick fix for you, just intercept the 'backrequested' and set it as handled:

var systemNavManager = Windows.UI.Core.SystemNavigationManager.getForCurrentView();
systemNavManager.addEventListener("backrequested", (event)=>event.handled = true, false);

Hope that helps!

NullOps
  • 1
  • 2