Associating answers with keyboard keys | XM Community
Skip to main content
In my current survey, I have two choices that are chosen by them being clicked on. I would like to associate each choice with a different keyboard key. I contacted Qualtrics' support team and was told that this can be done only by using JavaScript. Would anyone be able to help me how to do so? I have only two possible answers, and would like to associate the first one with the left arrow keyboard key and the second one with the right arrow keyboard key.
I have the exact same question and difficulty!

May anyone help us with this JavaScript situation?
Here is a solution that also allows you to use Enter to submit the page:



https://gist.github.com/mattbloomfield/de3a20a5180c274f79e7dfcaeb35ea66



Here is a solution that automatically submits the page when you choose left or right:



https://gist.github.com/mattbloomfield/e35b360fb259df583e17020abcec4ca9



Most browsers only hear `onkeydown` and `onkeypress` events for the arrow keys, so keep that in mind if doing this in the future: https://stackoverflow.com/questions/5597060/detecting-arrow-key-presses-in-javascript

Leave a Reply