1
Window / [SOLVED] Problem handling multiple key stroke
« on: May 13, 2024, 03:42:05 pm »
Hello everyone,
Its been a one year journey with SFML and everything has been great but i am facing a weird bug with inputs.
I am building a game so i have a HandleInput method in which i poll every event but when i am stroking 5 keys at the same time i get nothing (i tried to detect keyboard input using sf::Keyboard::isKeyPressed and by sf::Event.type and get the same bug)
Here is how i handle my event, this function is called by the main loop with 2 main functions, update and draw
I am building a local multiplayer game so this error bother me a bit, i don't know how can i solve this ?
Thanks for reading this and lmk if i didnt make this clear enough
Its been a one year journey with SFML and everything has been great but i am facing a weird bug with inputs.
I am building a game so i have a HandleInput method in which i poll every event but when i am stroking 5 keys at the same time i get nothing (i tried to detect keyboard input using sf::Keyboard::isKeyPressed and by sf::Event.type and get the same bug)
Here is how i handle my event, this function is called by the main loop with 2 main functions, update and draw
sf::Event event;
while (data->window.pollEvent(event))
{
if (sf::Event::Closed == event.type)
data->window.close();
else if (event.type == sf::Event::KeyPressed)
{
if (event.key.code == inputOfPlayers[0].moveUp)
{
//do things
}
else if (event.key.code == inputOfPlayers[0].moveDown)
{
//do other things
}
}
}
while (data->window.pollEvent(event))
{
if (sf::Event::Closed == event.type)
data->window.close();
else if (event.type == sf::Event::KeyPressed)
{
if (event.key.code == inputOfPlayers[0].moveUp)
{
//do things
}
else if (event.key.code == inputOfPlayers[0].moveDown)
{
//do other things
}
}
}
I am building a local multiplayer game so this error bother me a bit, i don't know how can i solve this ?
Thanks for reading this and lmk if i didnt make this clear enough