I want 9 different functions to be triggered by single button and keyboard numpad (1-9) in my After effects extension. I got some solution from stackoverflow and it works fine in online html editors but doesn't work in after effects. Below is the sample code. Can someone plz help.
<button type="button" id="b41" onclick="myFunction(event)">myButton</button>
<script>
const pressedButtons = {};
window.onkeydown = (e) => (pressedButtons[e.which] = true);
window.onkeyup = (e) => (pressedButtons[e.which] = false);
function myFunction(event) {
if (pressedButtons[97]) {
setOpacity_0();
} else if (pressedButtons[98]) {
setOpacity_100();
} else {
setOpacity_50();
}
}
</script>