Vizard 8 » Command Index » Vizard modules » viztask » <viztask>.waitKeyDown
8.0

<viztask>.waitKeyDown

Wait for a specified key press

<viztask>.waitKeyDown(  
keys  
)  
keys
Key to wait for.

If keys is a sequence, then the Condition will wait for one of the keys to be pressed.

If keys is None, then the Condition will wait for any key to be pressed.

Remarks

This command will create a Condition object that will wait for one of the specified keys to be pressed.

The yielded command returns a viz.Data object with the following information about the condition:

Properties

key

The key that was pressed

time

The precise time of the key press

Return Value

viztask.Condition object

Example

Example 1:
import viztask

def MyTask():

    while True:

        yield viztask.waitKeyDown(' ')

        print('Spacebar pressed')

viztask.schedule( MyTask() )

Example 2:
import viztask

def MyTask():

    while True:

        yield viztask.waitKeyDown(('a','b','c'))

        print('a, b, or c was pressed')

viztask.schedule( MyTask() )

Example 3:
import viztask

def MyTask():

    while True:

        d = yield viztask.waitKeyDown(None)

        print("Key '"+d.key+"' was pressed at time",d.time)

viztask.schedule( MyTask() )

See also

<viztask>.waitKeyChar
<viztask>.waitKeyUp