Prevent screen from scrolling when space is pressed | XM Community
Skip to main content

Hello,
In our task, we present a moving graphic (saved and uploaded as a video) to participants and they press the spacebar to stop the movement. It seems that there is a lot of space around the graphic itself and when participants press the spacebar, the screen scrolls down. I have been trying to prevent this from happening without success. I tried some codes which remove padding and space between questions, but they did not solve the issue. I would like the screen (and as a result the graphic) to stay in place when space bar is pressed. How can I prevent the scrolling down that is happening automatically with the press of the spacebar? Is there a javascript that can do this?
Thank you!

Try this javascript code.
Qualtrics.SurveyEngine.addOnReady(function () {
jQuery(document).on("keypress", function(e) {
if(e.keyCode == 32) {
e.preventDefault();
}
});
});


Leave a Reply