I control a single MC question (yes/no) with arrow keys (this is working so far):
Qualtrics.SurveyEngine.addOnload(function() {
var qid = this.questionId;
jQuery(document).keydown(function(event) {
console.log('keydown', event);
if (event.key == "ArrowLeft") {
event.preventDefault();
Qualtrics.SurveyEngine.registry[qid].setChoiceValueByRecodeValue(1, true);
jQuery('#NextButton').click();
} else if (event.key == "ArrowRight") {
event.preventDefault();
Qualtrics.SurveyEngine.registry[qid].setChoiceValueByRecodeValue(0, true);
jQuery('#NextButton').click();
}
});
});
This script is affecting all questions (not only the one in which I put the code), but I want to limit the key bindings to one specific question only. How can I remove the binding?
Solved
Controlling just one single question with keyboard, while disabling keyboard for all other questions
Best answer by TomG
You need to turn off the keydown event handler after the left or right arrow keys are pressed using jQuery .off().
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.
