Use keyboard arrows to scroll through multiple choice question responses | XM Community
Skip to main content
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.
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.
1. For All questions:Use this in header inside `<script><script>` (even then a click in the survey is required to activate the script)

2. For Specific Questions :Use this inside Onready function `<script><script>` (even then a click in the survey is required to activate the script or if the is the client has already clicked in prev question then it will run)
Wow - thank you so much for your quick response. Everything is working nicely now - thanks again 🙂

Leave a Reply