Solved
Javascript: Using Enter to advance after a delay
I've been using the following code from a gist to allow the use of the 'enter' key to advance to the next question in addition to the next button:
```
Qualtrics.SurveyEngine.addOnload(function()
{
/*Place your JavaScript here to run when the page loads*/
/*Advance on enter - modified from the following gist: */
/*https://gist.github.com/mattbloomfield/de3a20a5180c274f79e7dfcaeb35ea66*/
var qid = this.questionId;
document.onkeydown = function(event) {
console.log('keydown',event);
if (event.which == 13) {
event.preventDefault();
jQuery('#NextButton').click();
}
}
});
```
I want to delay the page advance for 3 seconds, which I'm currently doing through a timing question and enabling submit after 3 seconds.
However, I've noticed while testing that hitting the enter key can jump ahead before the 3 seconds are finished (when the next button is displayed). Does anyone know what the right way to incorporate this delay into the Javascript?
Best answer by fleb
Hi ,
I'd not use Qualtrics timing, but design my own timing in JS. You can use the `setTimeout() ` method.
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.
