title: Adding a cool down to a javascript key press
body: <p>I have a Jquery problem today using key Codes, my code dumb below</p>
  
  <pre><code>$(function() {
      var distance = 0;
      $('.right').click(function() {
          distance -= 100;
          $('#container').css('transform', 'translateX(' + distance + '%)')
          console.log(distance);
      });
      $('.left').click(function() {
          distance += 100;
          $('#container').css('transform', 'translateX(' + distance + '%);')
          console.log(distance);
      });
  
      $(window).keypress(function (e) {
        var code = e.keyCode || e.which;
      if(code == 13) {
         $('.right').trigger('click')
      }
      if(code == 9) {
         $('.right').trigger('click')
      }
      if(code == 32) {
         $('.right').trigger('click')
      }
      if(code == 39) {
         $('.right').trigger('click')
      }
      });
  });
  </code></pre>
  
  <p>So I am having some trouble making the arrow key presses work.</p>
  
  <pre><code>if(code == 32) {
      $('.right').trigger('click')
  }
  if(code == 39) {
      $('.right').trigger('click')
  }
  </code></pre>
  
  <p>Not only that but I can't seem to figure out a way to put a delay on it (1s) so it doesn't add a few hundred to the distance var when I only want it to do it once, so lets say instead of delay, a cool down.</p>
  
  <h2>UPDATE</h2>
  
  <p>While I'm at it I would like to ask if anyone has any solutions to putting a maximum and miniumum amount on</p>
  
  <pre><code>var distance = 0;
  </code></pre>