SFML community forums

Help => System => Topic started by: Carlitox on January 24, 2015, 11:07:47 pm

Title: [SOLVED] How to know when a key is released when I'm pressing two keys?
Post by: Carlitox on January 24, 2015, 11:07:47 pm
When there is only one key I use this function to check when one key is released:

if (GameApp::event.type == sf::Event::KeyReleased && GameApp::event.key.code == sf::Keyboard::Right)
{

}
 

But when there are two keys pressed at the same time and I release one the event it's not handled.


PD: Sorry it's solved, the code works but I was checking inside a function that it's executed only when a key it's pressed so  I wrote again the function.
Title: Re: How to know when a key is released when I'm pressing two keys?
Post by: Jesper Juhl on January 25, 2015, 03:41:51 pm
In general, it's pretty simple to keep track of keys yourself. Since you get an event on every key up/down it is fairly simple to keep track of "all keys currently pressed".
Title: Re: How to know when a key is released when I'm pressing two keys?
Post by: Laurent on January 25, 2015, 06:34:41 pm
In case you didn't notice, he already solved his problem.
Title: Re: How to know when a key is released when I'm pressing two keys?
Post by: Jesper Juhl on January 25, 2015, 07:10:45 pm
Whoops. Missed that.