Escape Test not responsive when execute as Command

Hi,

The test below is print messages in a loop and designed to stop when escape key is pressed.

I am experiencing a little issue with escape tests when a script is executed as a Command. The test went from start to finish without detecting Escape key when pressed.

Everything works as expected when run inside the Python Editor window and also through the command RunPythonScript and specify filename.

Any thoughts regarding fix/workaround ?

EscapeTest_cmd.py:

import scriptcontext
import rhinoscriptsyntax as rs

__commandname__ = "EscapeTest"

# RunCommand is the called when the user enters the command name in Rhino.
# The command name is defined by the filname minus "_cmd.py"
def RunCommand( is_interactive ):
    
    for i in range(100):
        print "index is now {} / 100".format(i)
        rs.Sleep(20)
        rs.Prompt("Press ESC to exit")
        if scriptcontext.escape_test(False):
            print "Escaped"
            break
        
    print "Test Complete"
    return 0

if __name__ == "__main__":
    RunCommand(False)