+ 1
Using the spacebar to play
Hey, I am wondering if I can use the spacebar as controls. The problem is that if I use the spacebar, it usually resets the program. Is there anyway for the spacebar not to reset the program? Thank you.
2 Respostas
+ 4
Yes.
You can code the desired action in the Keydown event callback function.
JS Keydown Event Listener
https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key
Because I am using SoloLearn mobile app, instead of keydown event, I used Mouse Click Event to demonstrate how to swap callback function.
https://code.sololearn.com/WX5Yv2zlP9JY/?ref=app
+ 2
https://code.sololearn.com/WhoIE9Xu2M28/?ref=app
https://code.sololearn.com/WhHCxetjRzTm/?ref=app