I am trying to make a game using PyGame that has left and right movement on the a/d keys. I have got this code but it will only detect a key down not a key hold:
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_SPACE:
if onPlatform == True:
onPlatform = False
ytarget = ylevel + 100
if event.key == pygame.K_a:
print("a")
xlevel = xlevel-2
if event.key == pygame.K_d:
xlevel = xlevel+2
I would like to use the pygame.key.get_pressed() method but I can't get it to work.
Note: this question: Pygame- detect if a key is held down? does not answer my question so please don't mark this as a duplicate of that, If you do find another answer though, please direct me there:)