using space to advance, autoadvance problem | XM Community
Skip to main content

Hi!

For my survey in Qualtrics, I have the following design:

  1. A word is shown on the screen (text/graphic question)
  2. at a certain point, participants need press “space” to advance to the next question (text entry), the advance button is hidden.
  3. Upon the same space press, the reaction time is registered (the time the word was shown on the screen until space was pressed)
  4. On the next page, the normal advance button is used instead of the space bar (so space shouldn’t work)
  5. On the next page, the cycle restarts and a new word is shown on the screen

I have tried the following code for the spacebar press (advancing) and the reaction times:

Qualtrics.SurveyEngine.addOnload(function () {
    
 let timeOnLoad = new Date().getTime();
 var that = this;
 Event.observe(document, 'keydown', function keydownCallback(e) {
  var choiceID = e.keyCode;
  if (choiceID) {
   let RT = new Date().getTime() - timeOnLoad;
    Qualtrics.SurveyEngine.setEmbeddedData("RT1", RT);
   console.log(RT);
   Event.stopObserving(document, 'keydown', keydownCallback);
   that.setChoiceValue(choiceID, true);
  }
 });
});

Qualtrics.SurveyEngine.addOnReady(function() {
    $('NextButton').hide();
    if($('PreviousButton')) $('PreviousButton').hide();
    var evt = document.on('keydown', function(e) {
        if (e.which == 32) {  //space bar pressed
            evt.stop();
            $('NextButton').click();
        }   
    });
});

As you can see, I use embedded data for the reaction times (but perhaps I could also use the timing question). Anyway, it all works, so the reaction times are measured upon space press and the page is forwarded. The only problem is the survey starts autoadvancing after the first space press if I leave the next questions open for a while. Even the questions that do not have the code for the space press in them start autoadvancing. How can I solve this?

 

Thanks!

This was solved in 

 


Leave a Reply