Pause a loop with a key press

Dear Daniel and Michael,
Thank you both for your help. I managed to achieve what I wanted adding this code in the trial routine (each frame):

''' check if a response is given and if it is p, set Pause_check to 1 '''
if trial_key.status == STARTED:
    if (len(theseKeys) > 0 and 'p' in theseKeys):
        Pause_check =1

In programming with a separate routine for the pause I actually followed some recommendations I think I found in the old psychopy forum.

Thank you again for the prompt response!