I am trying to set up a multiple choice question with two answer options that does the following things:
1. The time it takes the respondent to make a decision is recorded (I do this by adding a timing question)
2. Instead of using the mouse, I want respondents to use either of two designated keys on the keyboard to log their response
3. The respondent should then advance automatically to the next question/block once they made a decision
I found some code that should do exactly that (see below). However - for some reason I don't understand - it does the following things instead:
1. I need to select an answer with the mouse. Thus, pressing j or k in order to select an answer doesn't do the trick.
2. However, once I selected an answer with the mouse and I press either j or k, I do advance to the next question.
What could be going wrong here and how can I fix it? Thanks so much in advance!
Theresa
Qualtrics.SurveyEngine.addOnload(function()
{
this.hideNextButton();
this.hidePreviousButton();
var that = this;
Event.observe(document, 'keydown', function keydownCallback(e) {
var choiceID = null;
switch (e.keyCode) {
case 74: // 'j' was pressed
choiceID = 1;
break;
case 75: // 'k' was pressed
choiceID = 2;
break;
}
if (choiceID) {
Event.stopObserving(document, 'keydown', keydownCallback);
that.setChoiceValue(choiceID, true);
that.clickNextButton();
}
});
});
Source: https://sites.google.com/site/complexcognitionbgsu/data-collection-software/qualtricsadvanced
Best answer by LaurenK
View original