input = ''
for event in pygame.event.get():
    if event.type == pygame.KEYDOWN:
        if event.key == pygame.K_ESCAPE:
            playing = False
if event.key == pygame.K_w:
    input = input + 'w'
if event.key == pygame.K_s:
    input = input + 's'
if event.key == pygame.K_a:
    input = input + 'a'
How to get an input from user in Pygame and save it as a variable?