Vizard 7 » Command Index » Vizard modules » vizact » <vizact>.onkeydown
7.6

<vizact>.onkeydown

Registers a function to handle key down events

<vizact>.onkeydown(  
key  
func  
*args  
)  
key
The key to handle
func
The function to call when the key is pressed
*args
The arguments to pass to the function

Remarks

When the specified key is pressed down, the given function will be called with the passed arguments.

Return Value

A vizact.EventFunction object with the following methods:

Method

Description

<event>.setEnabled(val)

Enable/Disable the event function. The associated function will not be called while the event function is disabled. viz.TOGGLE can be used to toggle the state. Event functions are initially enabled.

<event>.getEnabled()

Get the enabled state of the event function.

<event>.remove()

Permanently unregister the event function.

Example

#Set background color to red when 'r' pressed
vizact.onkeydown('r',viz.clearcolor,viz.RED)

See also

<vizact>.onkeychar
<vizact>.onkeyup
<vizact>.whilekeydown