SFML community forums
Help => Window => Topic started by: acrin1 on October 21, 2007, 11:01:22 am
-
I'm reading the keyboard like so:
if (App.GetInput().IsKeyDown(sf::Key::F11)) ToggleInsMode();
if (App.GetInput().IsKeyDown(sf::Key::F10)) ToggleItemMode();
This is working ok but this method is reading the key continuously until the key is released. What's the best way to read a single keypress or turn off the continuous reading of keys?
Thanks
-
You could fire an event in your system if the key is known to be pressed the first frame and only use that event for calculations.
-
sf::Input is for reading real-time (continuous) inputs. It shouldn't be used to get single events like key presses.
Use the sf::Event::KeyPressed event instead.
-
sf::Input is for reading real-time (continuous) inputs. It shouldn't be used to get single events like key presses.
Use the sf::Event::KeyPressed event instead.
Thanks. I missed that in the tutorial.