1
Window / Re: KeyPressed triggers once and then continuously after being held for a while
« on: January 23, 2022, 12:43:15 am »In your setup code, tell the main window to turn off key repeat.
window.setKeyRepeatEnabled(false);
Windows has a keyboard repeat delay and repeat rate, you can set them in the keyboard preferences. When a key is pressed, windows sends WM_KEYDOWN. If it is still down after the repeat delay, windows starts sending WM_KEYDOWN with the KF_REPEAT flag at the rate in the preferences. When finally released, WM_KEYUP is sent.
So by default SFML uses the way windows is sending it (held key makes lots of down events, only 1 up event), unless you turn that off with setKeyRepeatEnabled.
(I don't know if other operating systems do it that way too, I'm just a windows coder)
Brilliant, thank you!