I am plotting some figures one after each other (closing the windows, to see the next one), but i need a way to interrupt the cycle and finish the script by pressing a key ("Esc" for example).
I try using mscrt.getch(), but doesn't work, any advice would be appreciated.
The core cycle is something like this:
for i, _ in enumerate(ID_SECTION):
    FIG = plt.figure(
            num=ID_SECTION[i],
            figsize=(10, 7.5),
            facecolor='w'
        )
    curve = FIG.add_subplot(
            1, 2, 1,
            adjustable='box',
            aspect='equal'
        )
    curve.scatter(x, y)
    plt.show()
    plt.close('all')
 
     
    