Associating answers with keyboard keys | XM Community
Skip to main content
Answer

Associating answers with keyboard keys

  • June 30, 2018
  • 2 replies
  • 165 views

marcomzp
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.

Best answer by mattyb513

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

2 replies

  • July 5, 2018
I have the exact same question and difficulty! May anyone help us with this JavaScript situation?

mattyb513
Level 4 ●●●●
Forum|alt.badge.img+6
  • Level 4 ●●●●
  • Answer
  • July 10, 2018
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