Hi Christina, unfortunately not. There is no IF/ELSE in Storyline. I would recommend looking to JavaScript for this solution as you would be able to program more efficiently. You can then communicate a result back to a Storyline variable called "enterpressed" to a value of either "Y" or "N" and show the feedback you would like. Make sure "enterpressed" has a value of "" to being with so you can detect a variable value change to either "Y" or "N".
Here's the JavaScript.
var player = GetPlayer(); document.addEventListener("keypress",function(e){ player.SetVar("enterpressed",(e.keyCode == 13 ? "Y" : "N")) });
As mentioned, have a trigger that is looking for a variable change on "enterpressed" with an IF statement. If "enterpressed" = "Y" then enter key was pressed. Have another event looking for the value "N".
Sorry, my script was terrible, the first line was incorrect.
var player = GetPlayer(); // <-- I've fixed this line document.addEventListener("keypress",function(e){ player.SetVar("enterpressed",(e.keyCode == 13 ? "Y" : "N")) });
5 Replies
Hi Christina, unfortunately not. There is no IF/ELSE in Storyline. I would recommend looking to JavaScript for this solution as you would be able to program more efficiently. You can then communicate a result back to a Storyline variable called "enterpressed" to a value of either "Y" or "N" and show the feedback you would like. Make sure "enterpressed" has a value of "" to being with so you can detect a variable value change to either "Y" or "N".
Here's the JavaScript.
As mentioned, have a trigger that is looking for a variable change on "enterpressed" with an IF statement. If "enterpressed" = "Y" then enter key was pressed. Have another event looking for the value "N".
Hope that makes some sense?
Hi Sam,
Thanks for your quick reply!
Do I need to set the execute Javascript when the timeline starts, or is it another trigger?
Thanks,
Christina
On timeline start.
Hi Sam,
Thanks for your help :)
It doesnt seem to be working - I have attached a picture of the triggers.
Let me know if there is something I am doing wrong with them.
Christina
Sorry, my script was terrible, the first line was incorrect.
This discussion is closed. You can start a new discussion or contact Articulate Support.