Forum Discussion
PaulDeHorn
8 years agoCommunity Member
Change Text Entry Variable without control losing focus?
Does anyone know of a way to change a text entry variable without control losing focus first? I'm simulating software behavior where as soon as a number is typed a description appears. Currently, I ...
GavinElliott-89
3 years agoCommunity Member
Hey Curtis and to anyone else who finds themselves here.
The code below detects when anyone types into any number of text input boxes on a Storyline slide. Whenever a key is pressed the text boxes lose focus for a millisecond and trigger the relevant 'lose focus' trigger in Storyline.
The 'console.log' line can be omitted from the code. If you keep it in, a message is displayed in the browser for testing purposes.Array.from(document.querySelectorAll('.acc-textinput')).forEach(el => {
el.addEventListener('keyup', () => {
console.log('someone is typing in a box...');
el.blur();
el.focus();
})
});
A Storyline file is attached to demonstrate. Simply publish to HTML (web) or SCORM.