diff -r d190fe5315bd -r cd82643bb6d9 src/context.c --- a/src/context.c Mon Jun 09 13:18:41 2025 +0200 +++ b/src/context.c Mon Jun 09 14:02:40 2025 +0200 @@ -147,6 +147,11 @@ asc_context.input.mouse_xrel = 0; asc_context.input.mouse_yrel = 0; + // reset key flags + for (unsigned int i = 0 ; i < SDL_NUM_SCANCODES ; i++) { + asc_clear_flag(asc_context.input.keys[i], ASC_KEY_RELEASE_FLAG|ASC_KEY_PRESS_FLAG); + } + // dispatch SDL events SDL_Event event; while (SDL_PollEvent(&event)) { @@ -183,10 +188,14 @@ break; } case SDL_KEYDOWN: - asc_context.input.keys[event.key.keysym.scancode] = true; + // we only set the down and press flags if the key is not already known to be down + if (asc_key_up(event.key.keysym.scancode)) { + asc_set_flag(asc_context.input.keys[event.key.keysym.scancode], ASC_KEY_DOWN_FLAG|ASC_KEY_PRESS_FLAG); + } break; case SDL_KEYUP: - asc_context.input.keys[event.key.keysym.scancode] = false; + // we can directly set the release flag - it will be cleared next round + asc_context.input.keys[event.key.keysym.scancode] = ASC_KEY_RELEASE_FLAG; break; } }