title: Monogame - Key 'Pressed' instead of 'Hold' to Jump
body: <p>Will keep this short and simple:</p>
  
  <p>I have a 2D game with a movable character, and I have written some code to allow my player to jump, like so: </p>
  
  <pre><code>if (Keyboard.GetState().IsKeyDown(Keys.Space) &amp;&amp; hasJumped == false)
  {
      sound.Play(volume, pitch, pan); // plays jumping sound
      position.Y -= 5f;               // position of jump
      velocity.Y = -10.5f;            // velocity of jump 
      hasJumped = true;
  }
  </code></pre>
  
  <p>However when I hold down the <KBD> Space Bar </KBD>, my player will continue to jump when he lands back to the ground, however I want my player to only jump <strong>once</strong> during the duration of holding down the <KBD> Space Bar </KBD>, then having to press it again to jump.</p>
  
  <p>I appreciate any help given.</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>My velocity resets in one of my collision if statements within my <code>Collision()</code> function: </p>
  
  <pre><code>if (rectangle.touchTopOf(newRectangle))
  {
      rectangle.Y = newRectangle.Y - rectangle.Height;
      velocity.Y = 0f;    // velocity reset
      hasJumped = false;
  }
  </code></pre>