0

How do I allow the document to listen for the space button being pressed (and call the function) but prohibit scrolling when the mouse is centered in a scroll section? (Hitting space bar should still call the function even if pressed in a scroll section).

$(document).keydown(function(e){
    if (e.keyCode==32 && !$(e.target).is("input")) {
      if (active.getState() === "act") {
        nogo();
      } else if (active.getState() === "unact") {
      go();
    }
  }
});
user3757990
  • 27
  • 1
  • 4
  • 1
    possible duplicate of [HTML prevent space bar from scrolling page](http://stackoverflow.com/questions/22559830/html-prevent-space-bar-from-scrolling-page) – user229044 Jul 02 '14 at 17:18
  • It's a very ambiguous what you are trying to achieve, but to block the page from scrolling when space bar is hit, use e.preventDefault(); http://codepen.io/imrekovacs/pen/tsyzG – Kovács Imre Jul 02 '14 at 17:23

0 Answers0