Moving forward to the next question by pressing the space bar | XM Community
Skip to main content
Hi guys!

I am trying to record a reaction time by using a combination of timing as well as having the participants click the screen or press the space bar to advance forward when detect something in a GIF. I'm not sure how to code for the page to advance as soon as the participant click the screen or presses the space bar. I know very little about Java Script, please help!



Thank you
Hi @esb, I answered a similar question here: https://www.qualtrics.com/community/discussion/1168/associating-answers-with-keyboard-keys



In this gist that I posted there (below), you could just eliminate lines 6-11 and then remove the `} else ` on line 12. Enter is key 13, which is what that final if statement is listening for. So you probably should change it to 32, for spacebar. You can get key codes here: http://keycode.info/



https://gist.github.com/mattbloomfield/de3a20a5180c274f79e7dfcaeb35ea66
Hi @esb , refer this javascript code..



var that = this;

Event.observe(document,'keydown',function(e){

var choiceID = null;

if (e.keyCode == 32) // if space was pressed

{

choiceID = 1;

}

if (choiceID)

{

that.setChoiceValue(choiceID,true);

that.clickNextButton();

}

Leave a Reply