Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: SMFL2: proper handling of 2 simultaneous keypresses?  (Read 2517 times)

0 Members and 1 Guest are viewing this topic.

tobybear

  • Newbie
  • *
  • Posts: 27
    • View Profile
SMFL2: proper handling of 2 simultaneous keypresses?
« on: March 23, 2010, 11:37:05 pm »
Hi!
I am using SFML2 and I am having a problem with GetInput().IsKeyDown() when two keys are pressed simultaneously, in my case the "Left" and the "Up" arrow keys:

In my code I use the following lines:
...
bool key_l=window.GetInput().IsKeyDown(sf::Key::Left);
bool key_u=window.GetInput().IsKeyDown(sf::Key::Up);
...

Now when I press the left and up arrow simultaneously, both bools above will be set to true (correct), but releasing both keys causes only the key_u to be set to false, not the key_l, which will then stay forever in "true" (not good for a jump n run, obviously :-)

Seems to happen only with specific key combinations though. Dunno, maybe it is my computer, but can I do anything about it?

Thx,
Toby

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
SMFL2: proper handling of 2 simultaneous keypresses?
« Reply #1 on: March 24, 2010, 08:22:45 am »
Keyboards usually have the other problem (some keys are not reported as down when you press too many of them), but yes it could be a keyboard issue too.

If so, there's nothing you can do about it. You can try your program on other computers to test if it's really caused by your own keyboard.
Laurent Gomila - SFML developer