title: Key Repetition in SFML 2.0
body: <p>Is there a way to receive if a key has just been pressed (not held) in SFML, or a way to mimic such an effect?</p>
  
  <p>I poll my event here,</p>
  
  <pre><code>while (window.pollEvent(event));
  </code></pre>
  
  <p>And then later in the loop, out of scope but with the same event, I read:</p>
  
  <pre><code>if (event.type == sf::Event::KeyPressed)
  {
      if (event.key.code == sf::Keyboard::Up)
      {
          decision--;
          if (decision &lt; 0)
          decision = CHARACTER_MAX - 1;
      }
  }
  </code></pre>
  
  <p>This makes <code>decision</code> decrement continuously when the up arrow is held down. Using <code>sf::event</code>s, can I read the first time it is pressed and not when it is held down?</p>
  
  <p>Also, if its not possible or you're not familiar with sfml, what would be the best way to mimic such with little or no globalized variables? (such as <code>is_already_held</code>), e.g. <a href="https://gamedev.stackexchange.com/questions/30826/action-button-only-true-once-per-press">https://gamedev.stackexchange.com/questions/30826/action-button-only-true-once-per-press</a></p>
  
  <p>I realize that such may be the only way (declaring a variable in a wider scope) but I would prefer not to, because I exit the scope continuously and try to steer clear from global variables as often as possible.</p>