pygame get key pressed as a string [duplicate]
问题 This question already has answers here : Pygame: Is there any easy way to find the letter/number of ANY alphanumeric pressed? (2 answers) Closed last year . I want to change the text in the controls screen based on the key which the user presses. how do I convert pygame.event.get() into a string that shows which key has been pressed? preferably without many if staments for event in pygame.event.get(): if event.type == pygame.KEYDOWN: slectedKey = # get key name as a string print(slectedKey)