SFML moving character in a window trouble

The problem i am having is that when a key is press and held, the character will move, stop, then move smoothly. Its like it you hold a key when your typing. The letter comes up, waits, and then more come up quickly. Is there a way to fix this? im using sfml 2.0 btw.

My current code is something like this. In case it isnt obvious, only the relevant parts are actual code, everything else is pseudo code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
while true
{
    xVelocity = 0;

    while(MainWindow.pollEvent(Event))
    {
   	if( Event.type == sf::Event::KeyPressed )
	{
               if( sf::Keyboard::isKeyPressed(sf::Keyboard::W))
                    xVelocity = 5;
        }
    }

   xPosition += xVelocity;

   Draw(x, y);
}
Incase anyone else ever has this problem, the problem is that the sf::keyboard does not need a window to work and should be placed outside of the while(window.pollEvent(Event)) loop.
Topic archived. No new replies allowed.