This is a part of my alphabet in my pygame code. It works perfectly fine, but takes up alot of lines and looks ugly. its also not portable. Ive tried to create a function for it that can add the letter to any variable, not just "username" in my case but haven't succeeded.
event_list = pygame.event.get()
for event in event_list:
pressed = pygame.key.get_pressed()
if pressed[pygame.K_a]:
username += "a"
if pressed[pygame.K_b]:
username += "b"
if pressed[pygame.K_c]:
username += "c"
# ....... etc etc
Does anyone have any suggestions on how i can turn this into a function?