Move focus to next Text Entry using Javascript

I have a slide with 4 text entry fields. Is there any way that I can move the cursor focus to the next text entry field (using javascript), when the user types a certain key on the text entry field using the command "When user presses a key"?

Or move the cursor to the next text entry field after limiting the number of characters in the text entry field?

2 Replies
Matthew Bibby

There is a Javascript library called keypress.js that you can use to do stuff when a certain key is pressed. See here for a demo.

Unfortunately, there isn't really a way to give focus to a certain text entry field in Storyline.

However, if you add a new layer to a slide that only contains a text entry field, then that text entry field may become selected when the slide layer opens (not sure if it works reliably in all browsers, haven't tested it).

So if you use keypress.js to trigger a variables change in SL when a certain key is pressed, then you can have a trigger in SL that will show a layer when that variable changes and (hopefully) the text entry field will become active.

In theory, the same could be done when a certain number of characters have been typed in the text entry field (you'd need to write custom JS to count the number of characters, but if you dig around the forums you'll find example code showing how to do this). 

Keep in mind that this will be pretty confusing for the learner. People don't expect the focus to change between text entry fields in this way. If you are making a software simulation of a piece of software that behaves in this way then it might be okay, but it'll probably just confuse people.

Sanduni Fernando

Thank you so much for your input Matt.

I was trying to achieve the 'entering credit card numbers' effect and thought the same could be used to crossword puzzles as well.

I checked in some forums and could not come with a suitable solution (I am not a javascript expert as well :( .)

Thank you for your advice on usability on changing focus. Will think of an alternative solution and update this thread, if I can come up with a satisfied alternative.