Keeping a count of key up events. Problems with .keyup / . keydown | XM Community
Skip to main content
Hi,



I'm creating a task in which participants are asked to remember pairs (displayed in a loop and merge block). The task is going to be completed from home. My worry is that participants will write down the correct answers rather than learn them (especially as correct remembering will be rewarded).



I decided to solve this that when the pairs are first presented I would ask participants to hold down the letters A and L on there keyboard. So they are unable to write. I was hoping to keep a count of key up events for these keys and therefore know if the task was not completed as instructed.



To start this I wrote this. Once this is working I'll add in an if statement so that I only record if they lift the keys they should be pressing. I was also hoping to track how long the keys are up for using the date too but I can't get this first step to work.



var countKeyUp =Number("${e://Field/countKeyUp}");







jQuery(".Skin").keyup(function() {

countKeyUp = countKeyUp +1;

Qualtrics.SurveyEngine.setEmbeddedData('countKeyUp', countKeyUp.toString());

console.log(countKeyUp);

})



The problem is that the code works fine on a question before my loop and merge block but once in the loop and merge block the exact same code doesn't seem to work at all. I can't even get it to print "keyup" to the console log on keyup.



Thanks
Be the first to reply!

Leave a Reply