Forum Discussion
JavaScript API
- 3 months ago
For your stated issue, you need to change the value in the third trigger on layer q5 to "Q5" instead of "q5" for Set currentQuestion. That fixes the key response.
Unrelated, but you are also missing a T/F SL variable "Q4Correct".
Another note is that in the second trigger JavaScript, for case 'Q5' you could change event.code to event.key just to be consistent with the other keypress checks. It doesn't change anything as the code and key for Pause are the same, but it makes the code clearer.
I implemented Nathan_Hilliard's suggestion and we are closer. I moved each question to a new layer, and now everything works except the wrong key on the last question which uses Pause/Break as the answer. It does nothing if you press the wrong key. What's missing? It looks the same as the others.
I wasn't sure if I needed to add Execute Javascript on each layer, but I added that trigger just in case.
Any suggestions?
#javascript DavidAnderson
For your stated issue, you need to change the value in the third trigger on layer q5 to "Q5" instead of "q5" for Set currentQuestion. That fixes the key response.
Unrelated, but you are also missing a T/F SL variable "Q4Correct".
Another note is that in the second trigger JavaScript, for case 'Q5' you could change event.code to event.key just to be consistent with the other keypress checks. It doesn't change anything as the code and key for Pause are the same, but it makes the code clearer.
- JeanMarrapodi-c3 months agoCommunity Member
That did it! Thanks so much Nathan_Hilliard. You are truly a JavaScript Juggernaut.
Here's the file if anyone ever needs to replicate something like this.
Related Content
- 4 months ago
- 3 years ago