Solved
Use keyboard arrows to scroll through multiple choice question responses
Hello,
I'm very new to using Javascript so would really appreciate any kind of advice I can get on this.
I have developed a survey in Qualtrics containing multiple response questions (each question contains 4 possible answers).
I'd like to add Javascript so that users of the survey can switch between the response option which is highlighted using the up and down keyboard arrow keys. I'd also like users to be able to hit the enter key to travel to the next page, and the delete key to travel to the last page. Is it possible to code this using javascript?
I'd be really grateful for any suggestions on how I could do this :)
Many thanks.
Best answer by NiC
jQuery(document).keydown(function(e) {
switch(e.which) {
case 8 : //backspace
jQuery("#PreviousButton").click()
break;
case 13://enter
jQuery("#NextButton").click()
break;
default: return; // exit this handler for other keys
}
e.preventDefault(); // prevent the default action (scroll / move caret)
});
this code can get you the Enter Key for next and and Backspace key for Prev(If Prev is enabled from the survey Options)
As for the Select Option you will need to manually Click an option as Qualtrics does not allow to emulate click or focus to be done for an option via script.
But after one of the option is selected then the arrow keys can be used to traverse between Options.
View originalLeave a Reply
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.