Add event like keydown or keyup for the controller keys or add in keydown & keyup event the controler keys
Use cases
When you need want to create a key bindings system that can use keyboard & controler
Describe the solution you'd like
Add an event called controlerkeydown & controlerkeyup or add this into keydown & keyup event
Describe alternatives you've considered
Actually, if you want to get an "keydown" or "keyup" for controllers, you need to call a native for checking if somes controls is pressed to get wich controller keys is down/up
Like this shitty code :
const controllerKeys = [
{
id: Keys.padUp,
pressed: false,
controls: [
Controls.sniperZoomInSecondary, // ]
Controls.phoneUp, // Arrow up
Controls.scriptPadUp, // Z
Controls.replayScreenshot, // U
],
},
];
alt.everyTick(ontick);
function onTick() {
controllerKeys.forEach((key) => {
const wasPressed = key.pressed;
key.pressed = true;
for (let i = 0; i < key.controls.length; i++) {
const control = key.controls[i];
if (!natives.isControlPressed(0, control) && !natives.isDisabledControlPressed(0, control)) {
key.pressed = false;
break;
}
}
if (key.pressed !== wasPressed) {
if (key.pressed) {
onKeyDown(key.id);
} else {
onKeyUp(key.id);
}
}
});
}
Additional context
For example, when you press the padUp of your controller, you can know with the event keydown/keyup (or controllerkeydown/controlerkeyup) wich key is pressed (x is a number or a string in this case)
Suggestion
Add event like keydown or keyup for the controller keys or add in keydown & keyup event the controler keys
Use cases
When you need want to create a key bindings system that can use keyboard & controler
Describe the solution you'd like
Add an event called controlerkeydown & controlerkeyup or add this into keydown & keyup event
Describe alternatives you've considered
Actually, if you want to get an "keydown" or "keyup" for controllers, you need to call a native for checking if somes controls is pressed to get wich controller keys is down/up Like this shitty code :
Additional context
For example, when you press the padUp of your controller, you can know with the event keydown/keyup (or controllerkeydown/controlerkeyup) wich key is pressed (x is a number or a string in this case)