go to new layer when text has been entered in text box

Mar 04, 2024

Hi. I have a text box where the user is supposed to enter the number 68, and then I want that specific number to trigger the opening of a new layer without having to enter any other key such as ENTER. The number itself should trigger the layer. Is this possible? I'm assuming I would need some JavaScript maybe? Thank you.

7 Replies
Nedim Ramic

I think you could use a bit help of Javascript. Something like this:

const textFields = document.querySelectorAll('.acc-textinput');

textFields.forEach((textField) => {
    textField.addEventListener('keyup', () => {
        textField.blur();
    });
});

Put this code in 'Execute Javascript when the timeline starts on this slide' trigger. 
The blur() method will remove keyboard focus from the current element. Create a trigger in SL to say: Show layer 'correct' when 'NumericEntry' changes if 'NumericEntry' = value 68. As soon as you type 68 into the input field another layer will show up.