SFML community forums

Help => Window => Topic started by: MickeyKnox on August 30, 2021, 07:53:59 pm

Title: [SOLVED] Prolonged key press timeout
Post by: MickeyKnox on August 30, 2021, 07:53:59 pm
When pressing a key an Event is fired for that key being pressed. After that there is a timeout, in which no Event is fired for the same key still being pressed. The timeout seems to be about one second. After the timeout an Event is fired every frame.

Is it possible to control the lenght of this timeout, setting it to 0? Or is it possible to simply disable the timeout?
Title: Re: Prolonged key press timeout
Post by: G. on August 30, 2021, 09:45:07 pm
No, it's user preferences dependent. For example in windows 10:
(https://i.imgur.com/uZQ8pwo.png)

You can disable key repeat with window.setKeyRepeatEnabled if you only want the first keypressed event.
Or you can set a boolean to true when the key pressed event is triggered and set it back to false when key released is triggered.
You can also always check the state of key with sf::Keyboard::isKeyPressed