SFML community forums
Help => Window => Topic started by: dkaip on March 12, 2010, 11:36:19 am
-
I am tryin in events to take the ctrl+left arrow event. First press ctrl, then left key.
How i can take this event?
-
if (event.Type == sf::Event::KeyPressed && event.Key.Code == sf::Key::Left && event.Key.Control)
{
...
}
-
As i see dont work ...
error: `event' was not declared in this scope
-
Well, this is not a complete code, you have to use this line into your event loop and adapt the variables names.
-
Ok i will try.
Thank's
Jim :)
---------------------------------------------------
trying ....
if (Event.Type == sf::Event::KeyPressed && Event.Key.Code == sf::Key::LControl && Event.Key.Code == sf::Key::Left ){ ... }
dont work ...
-
Of course, the same variable can't have two values at once. Check for Control first, set a bool flag, check for Left. Reset the flag when releasing the key.
However, I think that realtime input (the sf::Input class) is more appropriate than events. How realtime input handling works is described in the tutorials.
-
if (Event.Type == sf::Event::KeyPressed && Event.Key.Code == sf::Key::LControl && Event.Key.Code == sf::Key::Left ){ ... }
dont work ...
Read my previous answer twice, this is not the code that I gave you.
Check for Control first, set a bool flag, check for Left. Reset the flag when releasing the key.
There's no need to do so, The Event::Key structure directly provides the state of modifier keys (Control, Alt, Shift).
-
Ok i will try to read and understud the structure...
Thank's
Jim