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

Code before:
    // 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;
            }
            keyboard->keysource[scancode] |= source;
        } else {
            if (keyboard->keyrefcount[scancode] == 0) {
                return false;
            }
            keyboard->keyrefcount[scancode]--;
            if (keyboard->keyrefcount[scancode] == 0) {
                keyboard->keysource[scancode] = 0;
                last_release = true;
            }
        }

        // Update internal keyboard state
        if (down) {
            keyboard->keystate[scancode] = true;
        } else {
            if (keyboard->keyrefcount[scancode] == 0) {
                keyboard->keystate[scancode] = false;
            }
        }

        keycode = SDL_GetKeyFromScancode(scancode, keyboard->modstate, true);

    } else if (rawcode == 0) {
        // Nothing to do!
        return false;
    }

    if (source == KEYBOARD_HARDWARE) {
        keyboard->hardware_timestamp = SDL_GetTicks();
    } else if (source == KEYBOARD_AUTORELEASE) {

Review comment (suggestion):
```suggestion
            --keyboard->keyrefcount[scancode];
```
Typically in SDL we use the prefix operators so it reads naturally aloud, e.g. "decrement keyboard key reference count"

Code after:
    // 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;
            }
            keyboard->keysource[scancode] |= source;
        } else {
            if (keyboard->keyrefcount[scancode] == 0) {
                return false;
            }
            --keyboard->keyrefcount[scancode];
            if (keyboard->keyrefcount[scancode] == 0) {
                keyboard->keysource[scancode] = 0;
                last_release = true;
            }
        }

        // Update internal keyboard state
        if (down) {
            keyboard->keystate[scancode] = true;
        } else if (last_release) {
            keyboard->keystate[scancode] = false;
        }

        keycode = SDL_GetKeyFromScancode(scancode, keyboard->modstate, true);

    } else if (rawcode == 0) {
        // Nothing to do!
        return false;
    }

    if (source == KEYBOARD_HARDWARE) {
        keyboard->hardware_timestamp = SDL_GetTicks();
    } else if (source == KEYBOARD_AUTORELEASE) {
        keyboard->autorelease_pending = true;
    }