I am trying to code a left and right key stroke and record the response while participants watch a video. It seems the right arrow key is working but the left arrow key sends the video back 5 seconds insted of recording the response. This is the script I am using:
Qualtrics.SurveyEngine.addOnload(function() {
var qobj = this;
document.onkeydown = function(event) {
console.log('keydown',event);
if (event.key == 'ArrowLeft') {
event.preventDefault();
qobj.setChoiceValue(1, true);
Qualtrics.SurveyEngine.setEmbeddedData('Practice 1 answer', 1);
qobj.clickNextButton();
} else if (event.key == 'ArrowRight') {
event.preventDefault();
qobj.setChoiceValue(2, true);
Qualtrics.SurveyEngine.setEmbeddedData('Practice 1 answer', 2);
qobj.clickNextButton();
}
}
});