I created a program to demonstrate my problem below. To replicate hold down A, then hold down shift. Release A, then release shift. The program now prints that A is held down even though A was released. One can do the same with D.
#include <SFML/Graphics.hpp>
#include <iostream>
int main()
{
// Create the main window
sf::RenderWindow window(sf::VideoMode(800, 600), "SFML window");
bool ADown = false;
bool DDown = false;
// Start the game loop
while (window.isOpen())
{
// Process events
sf::Event event;
while (window.pollEvent(event))
{
// Close window: exit
if (event.type == sf::Event::Closed)
window.close();
if (event.type == sf::Event::KeyPressed) {
if(event.key.code == sf::Keyboard::Key::A)
ADown = true;
else if(event.key.code == sf::Keyboard::Key::D)
DDown = true;
}
else if (event.type == sf::Event::KeyReleased) {
if(event.key.code == sf::Keyboard::Key::A)
ADown = false;
else if(event.key.code == sf::Keyboard::Key::D)
DDown = false;
}
}
std::cout << "A: " << ADown << ", D: " << DDown << "\n";
// Clear screen
window.clear();
// Update the window
window.display();
}
return EXIT_SUCCESS;
}
I run archlinux and sfml 2.3.2
Thanks in advance.