I still have a problem though the code is definitely better. Basically the button works only on one of the event (the rest works)
The reason I need both is because some students will use only the keyboard and some students will use touch or mouse. I used mouse in the example but of course I could replace with touch which would also both mouse and tap.
case 1:
on start layout set trailOnOff = 1
on trailONoff = 0/ set animation frame to 0
else/ set animation frame to 1
result: keyPress changes the button - mouse does not
case 2:
on start layout set trailOnOff = 1
on trailONoff = 0/ set animation frame to 1
else/ set animation frame to 0
result: keyPress does not change the button - mouse does