I am running an experimental psychology test in python. In a part of my experiment, I need to rotate a single oriented bar to left or right. I use the following lines of codes to do that.
pygame.event.pump()
pressed = pygame.key.get_pressed()
BO = randint(0,180)
if pressed[pygame.K_LEFT]:
BO -= 1
thisExp.addData('adj_final_ori',BO)
if pressed[pygame.K_RIGHT]:
BO += 1
thisExp.addData('adj_final_ori',BO)
everything works fine, and I can adjust the orientation of the bar when I hold down the Left or Right keys, but the problem is that some times(not always) even after releasing the key the line keeps rotating and I have to push the same key to stop it. Any Idea how to solve this problem?