How to remove the scroll when you tap the spacebar?

Good day!

How can I remove scrolling page when you click on the spacebar ?
June 26th 19 at 13:57
1 answer
June 26th 19 at 13:59
Something like this:
window.addEventListener('keydown', function(event) {
 if (event.keyCode === 32 && event.target === document.body) {
event.preventDefault();
}
});

Find more questions by tags CSSHTMLJavaScript