Reaction Time to The First Key Press | XM Community
Skip to main content

Hi everyone, I am trying to get the RT to the first key press not the first click. I added a JS code in the question in which I want to get the RT. Before that question I added an embedded data with the name of the variable I defined for the RT named as RT. This embedded data and the JS code in which the RT variable is defined is not on the same page as I saw a comment claiming that otherwise the variable is not saved. Yet, the variable RT is still not updated in the data. Do you have any ideas?

The JS code is in a question in the block named "Pişmanlık Anısı"
image.png
And this is the code I use for RT:

Qualtrics.SurveyEngine.addOnload(function () {
 let timeOnLoad = new Date().getTime();
 var that = this;
 Event.observe(document, 'keydown', function keydownCallback(e) {
  var choiceID = e.keyCode;
  if (choiceID) {
   let RT = new Date().getTime() - timeOnLoad;
   console.log(RT);
   Event.stopObserving(document, 'keydown', keydownCallback);
   that.setChoiceValue(choiceID, true);
  }
 });
});

A Qualtrics embedded data field and a JS variable are not the same thing. You need to add the line:
Qualtrics.SurveyEngine.setEmbeddedData("RT", RT);


TomG thank you for the reply. I added that line at the end of the JS code but still RT column is empty in the data. When I tried it like
Qualtrics.SurveyEngine.setEmbeddedData("RT", 5); it shows 5 in the data. So maybe there is a problem with the code that I am trying to create RT. But I cannot see what does not work. Do you have any idea how I can check if I can successfully create RT although I do not see it in the data sheet?


That line of code has to be inside the event - where console.log(RT) is. BTW, if you are seeing the correct value for RT in the console, then you code is working correctly.


Leave a Reply