Hi all,
I'm creating an experiment that requires participants to categorise a photograph. Each question is currently presented in a different block. Each block contains a picture, a multiple choice question, and a timing question (stimulus presentation is 2 seconds).
I would like to hide the multiple choice question/answer options, and have participants respond via keyboard press (rather than by selecting the answer with via the mouse). I have the below code, although this does not seem to work. Does anyone notice any errors here? Under which question (within the block, e.g. picture, MCQ or timing question) should I place this code? As the stimulus presentation is 2 seconds, I do not want to advance to the next page after the keyboard press.
TIA for the help.
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;
case 76: // 'L' was pressed
choiceID = 3;
break;
}
if (choiceID) {
Event.stopObserving(document, 'keydown', keydownCallback);
that.setChoiceValue(choiceID, true);
}
});
});
Be the first to reply!
Leave a Reply
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.