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);
}
}
});
Sign up
Already have an account? Login
Welcome! To join the Qualtrics Experience Community, log in with your existing Qualtrics credentials below.
Confirm your username, share a bit about yourself, Once your account has been approved by our admins then you're ready to explore and connect .
Free trial account? No problem. Log in with your trial credentials to join.
No free trial account? No problem! Register here
Already a member? Hi and welcome back! We're glad you're here 🙂
You will see the Qualtrics login page briefly before being taken to the Experience Community
Login with Qualtrics
Welcome! To join the Qualtrics Experience Community, log in with your existing Qualtrics credentials below.
Confirm your username, share a bit about yourself, Once your account has been approved by our admins then you're ready to explore and connect .
Free trial account? No problem. Log in with your trial credentials to join. No free trial account? No problem! Register here
Already a member? Hi and welcome back! We're glad you're here 🙂
You will see the Qualtrics login page briefly before being taken to the Experience Community
Login to the Community
Welcome! To join the Qualtrics Experience Community, log in with your existing Qualtrics credentials below.
Confirm your username, share a bit about yourself, Once your account has been approved by our admins then you're ready to explore and connect .
Free trial account? No problem. Log in with your trial credentials to join.
No free trial account? No problem! Register here
Already a member? Hi and welcome back! We're glad you're here 🙂
You will see the Qualtrics login page briefly before being taken to the Experience Community
Login with Qualtrics
Welcome! To join the Qualtrics Experience Community, log in with your existing Qualtrics credentials below.
Confirm your username, share a bit about yourself, Once your account has been approved by our admins then you're ready to explore and connect .
Free trial account? No problem. Log in with your trial credentials to join. No free trial account? No problem! Register here
Already a member? Hi and welcome back! We're glad you're here 🙂
You will see the Qualtrics login page briefly before being taken to the Experience Community
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 ?