What is the correct way to listen on keypress events from the Xbox gamepad?
Buzzwords: UWP, HTML/CSS/JS, React, Typescript
What is the correct way to listen on keypress events from the Xbox gamepad?
Buzzwords: UWP, HTML/CSS/JS, React, Typescript
You could first listen to the GamepadAdded event. You would get the Gamepad
class object by the event args when the the GamepadAdded
event is fired.
Then, you could call its GetCurrentReading() method to get which button is pressed.
Didn't try Xavier's method, we do it like this:
const systemMediaControls = Windows.Media.SystemMediaTransportControls.getForCurrentView();
systemMediaControls.addEventListener('buttonpressed', eventHandler)