SFML - Keyboard events
<p>Trying to figure out how to close a window using a button, in this case the 'Esc'-button. In my first approach I tried going like this:</p>

<pre><code>if (sf::event.type == sf::Keyboard::Escape)
    window.close();
</code></pre>

<p>That didn't turn out very well, doesn't look like my program notices me pressing the Escape button. So I tried this approuch:</p>

<pre><code>if (sf::event.type == sf::Keyboard::isKeyPressed(sf::Keyboard::Esc))
    window.close();
</code></pre>

<p>That didn't work either, and just before I was about to ask here I figured out that this line actually works (thou it doesn't feel right since I am actually handling events?)</p>

<pre><code>if (sf::Keyboard::isKeyPressed(sf::Keyboard::Esc))
    window.close();
</code></pre>

<p>My question is; what is the right way to do it? And why doesn't if work writing like I did first? It seems that' according to YouTube-videos the first and second approach works. But in SFML 2.0 and forward, only the last one does. Is that the case?</p>