Hi,
I'm asking participants to press the space bar 5 times when presented a specific question, and so would like to record how many times they press the space bar when presented with the question. Is this possible using javascript?
Thanks in advance!
Solved
Using javascript to record how many times a button is pressed
Best answer by rondev
Use the below code:
Qualtrics.SurveyEngine.addOnReady(function() {
var i = 0;
document.onkeydown = function(event) {
if(event.which == 32){
event.preventDefault();
i++;
Qualtrics.SurveyEngine.setEmbeddedData("count",i);
}
}
});
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.


I have created an embedded variable "count" at the start of the survey flow, but nothing seems to be registering when pressing "D". Could you tell me exactly how the embedded variable should look in the survey or let me know if you see any errors?