Reputation: 5
In pure Javascript, I have made a function that turns a toggle button on and off using the space bar (key 32) but I would like it to stop making the page scroll down as well. How do I go about doing this?
Upvotes: 0
Views: 76
Reputation: 5766
After you check to make sure the key pressed was the space bar, add e.preventDefault()
or whatever you named your event as in your parameters.
Upvotes: 1