SFML : multiple key issue
if (Keyboard::isKeyPressed(Keyboard::Space))
{
std::cout << "Space" << std::endl;
}
if (Keyboard::isKeyPressed(Keyboard::Left))
{
std::cout << "Left" << std::endl;
}
if (Keyboard::isKeyPressed(Keyboard::Right))
{
std::cout << "Right" << std::endl;
}
if (Keyboard::isKeyPressed(Keyboard::Up))
{
std::cout << "Up" << std::endl;
}
output:
CASE 1:
1) When pressed Up + Left + Space :
Up
Left
Space
2) When Pressed Up + Right + Space :
Up
Right
After searching for a while I found out that most keyboards can only only register a certain number of key presses at any given time, and ignore any subsequent key presses until you release one or more of the current keys. This doesn't apply to modifier keys (like Ctrl, alt, and shift) . So I checked it by replacing "Space" key by with "LAlt". The output was :
CASE 2:
1) When pressed Up + Left + LAlt :
Up
Left
LAlt
2) When Pressed Up + Right + LAlt :
Up
Right
LAlt
This works as expected but........if keyboards can only only register a certain number of key presses at any given time
then why was "space" key detected when pressed along with "up" and "left" key and not with "up" and "right" key?
Is this an issue with sfml? I just want to confirm whether it is indeed the issue where keyboard is unable to register multiple key press at same time.
I am trying to fire bullets from a spaceship. I am able to shoot bullets while moving forward and steering left but unable to shoot while steering right. I would really appreciate any help.