Every time I hit the "x" key, it shows two outputs instead of one.
Code:
#include <SFML/Graphics.hpp>
#include <iostream>
int main()
{
sf::Vector2f screenDimensions(800, 600);
sf::RenderWindow Window;
Window.create(sf::VideoMode(screenDimensions.x, screenDimensions.y), "Test", sf::Style::Titlebar | sf::Style::Close);
Window.setKeyRepeatEnabled(false);
int i = 0;
while(Window.isOpen())
{
sf::Event Event;
while(Window.pollEvent(Event))
{
if(sf::Keyboard::isKeyPressed(sf::Keyboard::X))
{
std::cout << i << std::endl;
i++;
}
}
}
}
Output (when pressing "x" key once):
0
1
How do I fix it so that it only detects and outputs one?
EDIT: I'm on Windows 7 and using SFML 2.1.