Hi everyone,
I'm new on this forum.
I'm here because i try to record the number of time a participant press a key when a text is displayed on the screen. So i try to adapt a script i fund here to build this function (my only training in programmation is a 20 hours tuto on openclassroom...). I add the script in the question (in fact in the descriptive text). Here is my attempt :
Qualtrics.SurveyEngine.addOnReady(function() {
let questionId = "NumberOfPushG" ;
document.onkeydown = function(event) {
let i = 0
if (event.which == 71){
event.preventDefault();
i += 1
Qualtrics.SurveyEngine.registry[questionId].setChoiceValue(i);
}
}
});
Of course it doesn't work i would not be here otherwise... 😥
What am i doing wrong ?
Thank you in advance to everyone.
How to count the number of time a participant push a key ?
Best answer by TomG
You have a number of logic and syntax errors. For starters, NumberofPushG isn't a valid questionId. Also, you can't set a value for a Descriptive Text question.
Try:
Qualtrics.SurveyEngine.addOnReady(function() {
var i = 0;
document.onkeydown = function(event) {
if(event.which == 71){
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.

So, i try to add an embedded data, i suppose it's a block " Embedded data" but where can i find how to define " count "
Is it here ?