SFML community forums
Help => Window => Topic started by: r1nux on September 08, 2008, 11:27:22 pm
-
I'm looking for the feature to not only read out if a key is pressed (with App.GetInput()).
In my utopia the Input-class would have the following functions:
IsKeyDown (only returns true the first time a key is being pressed)
IsKeyPressed (returns true every time a key is pressed)
IsKeyReleased (returns true when and only when the key has been released)
I have tried to "simulate" this by myself but without success.
If anyone could help me simulate this or point me in the right direction
I would happily be satisfied with that.
Best regards.
-
you can do that with Event class ;)
-
you can do that with Event class ;)
Ahh, thats true.
Tho im still not getting hang of how to implement a check for a single keypress.
What I'm meaning with that is that i want to seperate
onKeyPress and onKeyDown.
Hard to explain and definitive in the wrong forum-section for this kind of topic.
-
Key down is a state, you can request it anytime :
bool KeyDown = Win.GetInput().IsKeyDown(sf::Key::xxx);
bool KeyUp = !Win.GetInput().IsKeyDown(sf::Key::yyy);
While key press is an event, it happens once and it wouldn't make sense to request it; instead you're notified when it happens :
sf::Event Event;
while (Win.GetEvent(Event))
{
if ((Event.Type == sf::Event::KeyPressed) && (Event.Key.Code == sf::Key::xxx))
{
...
}
}
This is well explained in the tutorials.