Hi,i am a beginner and im trying to make my first project,and i have encountered a problem i dont know ,and cant find a solution to:

As you can see from the picture, im a making a “simple” project where a ball randomly moves and it randomly changes color from red to green.And the problem, i have is when the ball changes color to green and i get a string "Press “Space” " i cant seem to make it so when i press the “Space” the ball stops moving.If anyone could help me a bit i would be very grateful.