you need a keyboard listener.
You can build your own with ctypes, or use one of the available packages: https://pypi.org/search/?q=keyboard
If you choose keyboard package: https://pypi.org/project/keyboard/
see examples on README
pygame has built in event handler for this (I'm only slightly familiar with pygame as 99% of my code is not game related),
but see: https://code-knowledge.com/create-game-w...ard-input/
You can build your own with ctypes, or use one of the available packages: https://pypi.org/search/?q=keyboard
If you choose keyboard package: https://pypi.org/project/keyboard/
see examples on README
pygame has built in event handler for this (I'm only slightly familiar with pygame as 99% of my code is not game related),
but see: https://code-knowledge.com/create-game-w...ard-input/