Espere até pressionar Escape

import keyboard
# wait until you press escape
keyboard.wait('esc')
Arthur Adriansens