Forum Discussion

thartofylaka's avatar
thartofylaka
Community Member
9 days ago

Invalid answer dialogue

Hi all, is there a way to close the Invalid answer dialogue box with the escape key? It keeps creating problems at the accessibility check and it was marked as a possible solution from the testers. Thanks!

1 Reply

  • Hi thartofylaka​ 

    1. First you will need to create a Storyline Number variable called esc.

    2. Then add the following JavaScript to the MASTER SLIDE of your project (timeline starts trigger).

      if(!window.customStorylineHandleEscKey)
      {
      	
      	window.customStorylineHandleEscKey = function(e) 
      	{
      		if (e.key === 'Escape' || e.keyCode === 27) 
      		{
      			let num = Number(getVar('esc')) + 1;
      			setVar('esc', num);
      		}
      	}
      	document.addEventListener('keydown', window.customStorylineHandleEscKey);
      }

       

    3. Every time the user selects the ESC key, it will increment the Storyline esc variable by 1. This means you can then trigger any behaviour you would like to based on the esc variable value change, for example, hiding a layer:

    Use are your own risk as you will need to determine if this interferes with any other ESC key functionality in the browser.

OSZAR »