def METHOD_NAME(self, scanCode: int, isReleased: bool, isExtended: bool):
    keyName = scancode.getKeyName(
        scanCode, isExtended, self.shiftPressed, self.capsLockOn
    )
    # Update the state that tracks capitalization.
    if scanCode in [0x2A, 0x36]:
        self.shiftPressed = not isReleased
    elif scanCode == 0x3A and not isReleased:
        self.capsLockOn = not self.capsLockOn
    # Keep track of active modifiers.
    if scancode.isModifier(scanCode):
        if isReleased:
            self.mods.discard(keyName)  # No-throw
        else:
            self.mods.add(keyName)
    # Add the event
    self.json[JSON_KEY_EVENTS].append(
        {
            "timestamp": self.timestamp,
            "type": "key",
            "data": {
                "key": keyName,
                "press": not isReleased,
                "mods": list(self.mods),
            },
        }
    )