peekEvent ?-mask str? ?-delay num?
This command looks in the events queue for some type of event and executes it. This is useful for intercepting mouse clicks or keyboard events during the execution of a lengthy operation (such as a long while loop).
The -mask option indicates the events you want to allow. Its value is the sum of one or more flags with the following meaning:
EventFlag
Mouse Down1
Key Down2
The default value is 1.
The -delay option specifies a timeout. It indicates how long the command should wait until a requested event occurs. Its value is a floating value corresponding to a duration in seconds (for instance, set it to 0.001 for 1 millisecond). The default value is 0.0 which means that the command will just look if a requested event has been received and will immediately stop waiting. A value -1 on the contrary means waiting without limit.