SFML community forums
Help => Graphics => Topic started by: lorence30 on May 26, 2015, 03:41:53 pm
-
How to make so when i hold a key it wont have a delay.
say i i have a car, when i hold Left button it wont have any delay before the 2nd move of the car
-
Please describe your problem better, I've no idea what you want to achieve.
Also don't post the exact same question twice, I removed the other topic.
-
sf::Keyboard::isKeyPressed (http://www.sfml-dev.org/tutorials/2.3/window-inputs.php#keyboard) outside the event loop
-
If you want to continue using events, you can also check out the "The KeyPressed and KeyReleased events" section of the events tutorial: http://www.sfml-dev.org/tutorials/2.3/window-events.php. It describes what that delay is you are seeing and gives an idea of how to get around it by setting window.setKeyRepeatEnabled(false) and then use variables to hold the state of the keys. Alternatively, you can switch to using sf::Keyboard::isKeyPressed as G. mentioned.
-
get around it by setting window.setKeyRepeatEnabled(false) and then use variables to hold the state of the keys.
If you're storing the states of the keys, it shouldn't be necessary to remove the repeat as each repeated keypress just sets it to the state it is in already.