Breaking loop with a keypress?


i’m working on a script that is based on a main for loop where all calculations take place. since this loop could take quite some time to execute, i would like to give the user the option of aborting in the middle of the loop. is there any way of breaking the loop if a certain key was pressed? I have tried to use gui events to set a flag telling the script to break the loop, but it seems that the gui doesn’t receive events when the loop is running.

thanks in advance

Added a function for this. in 2.46+…

  • Window.TestBreak() - Returns true if the user has pressed escape.

nice, very useful.

nice indeed. thanks.

Is this still working?
I can’t find this function in 2.63.