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

Prevent screen from scrolling when space is pressed

  • February 1, 2021
  • 1 reply
  • 688 views

Forum|alt.badge.img

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!

1 reply

Forum|alt.badge.img+8
  • Level 2 ●●
  • 77 replies
  • February 10, 2021

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


Leave a Reply