Repository: libsdl-org/SDL
File: src/events/SDL_keyboard.c (C)

Code before:
        keycode = SDL_GetKeymapKeycode(keymap, scancode, modstate);

        if (keyboard->keycode_options & KEYCODE_OPTION_HIDE_NUMPAD) {
            keycode = SDL_ConvertNumpadKeycode(keycode, numlock);
        }
        return keycode;
    }

    return SDL_GetKeymapKeycode(keyboard->keymap, scancode, modstate);
}

SDL_Scancode SDL_GetScancodeFromKey(SDL_Keycode key, SDL_Keymod *modstate)
{
    SDL_Keyboard *keyboard = &SDL_keyboard;

    return SDL_GetKeymapScancode(keyboard->keymap, key, modstate);
}

static bool SDL_SendKeyboardKeyInternal(Uint64 timestamp, Uint32 flags, SDL_KeyboardID keyboardID, int rawcode, SDL_Scancode scancode, bool down)
{
    SDL_Keyboard *keyboard = &SDL_keyboard;
    bool posted = false;
    SDL_Keycode keycode = SDLK_UNKNOWN;
    Uint32 type;
    bool repeat = false;
    bool last_release = true;
    const Uint8 source = flags & KEYBOARD_SOURCE_MASK;

#ifdef DEBUG_KEYBOARD
    SDL_Log("The '%s' key has been %s", SDL_GetScancodeName(scancode), down ? "pressed" : "released");
#endif

    // Figure out what type of event this is
    if (down) {
        type = SDL_EVENT_KEY_DOWN;
    } else {
        type = SDL_EVENT_KEY_UP;
    }

    if (scancode > SDL_SCANCODE_UNKNOWN && scancode < SDL_SCANCODE_COUNT) {
        // Drop events that don't change state
        if (down) {
            if (keyboard->keyrefcount[scancode] < 255) {
                keyboard->keyrefcount[scancode]++;
            }
            if (keyboard->keystate[scancode]) {
                if (!(keyboard->keysource[scancode] & source)) {
                    keyboard->keysource[scancode] |= source;
                    return false;
                }
                repeat = true;

Review comment (suggestion):
```suggestion
    bool last_release = false;
```

Code after:
        keycode = SDL_GetKeymapKeycode(keymap, scancode, modstate);

        if (keyboard->keycode_options & KEYCODE_OPTION_HIDE_NUMPAD) {
            keycode = SDL_ConvertNumpadKeycode(keycode, numlock);
        }
        return keycode;
    }

    return SDL_GetKeymapKeycode(keyboard->keymap, scancode, modstate);
}

SDL_Scancode SDL_GetScancodeFromKey(SDL_Keycode key, SDL_Keymod *modstate)
{
    SDL_Keyboard *keyboard = &SDL_keyboard;

    return SDL_GetKeymapScancode(keyboard->keymap, key, modstate);
}

static bool SDL_SendKeyboardKeyInternal(Uint64 timestamp, Uint32 flags, SDL_KeyboardID keyboardID, int rawcode, SDL_Scancode scancode, bool down)
{
    SDL_Keyboard *keyboard = &SDL_keyboard;
    bool posted = false;
    SDL_Keycode keycode = SDLK_UNKNOWN;
    Uint32 type;
    bool repeat = false;
    bool last_release = false;
    const Uint8 source = flags & KEYBOARD_SOURCE_MASK;

#ifdef DEBUG_KEYBOARD
    SDL_Log("The '%s' key has been %s", SDL_GetScancodeName(scancode), down ? "pressed" : "released");
#endif

    // Figure out what type of event this is
    if (down) {
        type = SDL_EVENT_KEY_DOWN;
    } else {
        type = SDL_EVENT_KEY_UP;
    }

    if (scancode > SDL_SCANCODE_UNKNOWN && scancode < SDL_SCANCODE_COUNT) {
        // Drop events that don't change state
        if (down) {
            if (keyboard->keyrefcount[scancode] < 255) {
                keyboard->keyrefcount[scancode]++;
            }
            if (keyboard->keystate[scancode]) {
                if (!(keyboard->keysource[scancode] & source)) {
                    keyboard->keysource[scancode] |= source;
                    return false;
                }
                repeat = true;