crogine
crogine copied to clipboard
setKeyRepeatEnabled
Hi,
xygine has a function called setKeyRepeatEnabled which can be used to avoid firing events when a key is pressed. It is used in the following way:
getRenderWindow()->setKeyRepeatEnabled(false);
Does crogine has something similar? Right now if I left a key pressed, it keeps firing KEY_DOWN events.
SDL2 handles this slightly differently - the key down event has a repeat field: https://wiki.libsdl.org/SDL2/SDL_KeyboardEvent
You'd do something like:
if (evt.type == SDL_KEYDOWN)
{
if (!evt.key.repeat)
{
//handle event
}
}
If it would be useful I could wrap this in a function to toggle repeated key presses by preventing any repeated events from being forward from the window.