Example: Before and After Events
Connect a gamepad to the computer, then press the Start and Select buttons and see the numbers update below.
Select pressed: 0 times.
Start pressed: 0 times.
This is achieved using the .before() and .after() event handlers.
And it can be really convenient in many situations: setting up timers, mimic a single press
instead of a continuous one, etc.
How it works
The .before() and .after() methods work in a similar way to how
.on() does:
gamepad.before(EVENTNAME, CALLBACK);
gamepad.on(EVENTNAME, CALLBACK);
gamepad.after(EVENTNAME, CALLBACK);
These methods can be chained to allow a more fluid development. So the example above could also be written as:
gamepad.before(EVENTNAME, CALLBACK);
.on(EVENTNAME, CALLBACK);
.after(EVENTNAME, CALLBACK);