How to code a key press to incorporate display logic?

amarieamarie Community Member Qubie ✭

How to code a key press to incorporate display logic?

Hi everyone!

I'm trying to incorporate a key press with some display logic and am struggling a bit (I am new to Javascript).

Basically, I have a question, and if a participant presses a spacebar in response to this question, they get directed to one question, and if they don't, they get directed to another.

So far I have:

Qualtrics.SurveyEngine.addOnload(function() {

var qid = this.questionId;


document.onkeydown = function(event) {

console.log('keydown',event);

if (event.which == 32) {

event.preventDefault();

jQuery('#NextButton').click()


}

}


})


I have no idea how to incorporate the display logic I desire...can anyone help? Thank you!

Tagged:
Sign In to Comment