Moai SDK  2.0
MOAIKeyboardSensor Class Reference
+ Inheritance diagram for MOAIKeyboardSensor:

Function List

keyDown
 
keyIsDown
 
keyIsUp
 
keyUp
 
setCallback
 
setCharCallback
 
setEditCallback
 
setKeyCallback
 

Function Documentation

keyDown

Checks to see if one or more keys were pressed during the last iteration.


function keyDown ( MOAIKeyboardSensor self, ... )

Parameters
MOAIKeyboardSensorself
...keys Keys to be checked against the input table. Each key can be specified using a MOAIKeyboardSensor.* constant or the corresponding string. Multiple strings can be combined: 'wasd' is equivalent to 'w', 'a', 's', 'd'.
Returns
boolean... down
keyIsDown

Checks to see if one or more keys are currently pressed.


function keyIsDown ( MOAIKeyboardSensor self, ... )

Parameters
MOAIKeyboardSensorself
...keys Keys to be checked against the input table. Each key can be specified using a MOAIKeyboardSensor.* constant or the corresponding string. Multiple strings can be combined: 'wasd' is equivalent to 'w', 'a', 's', 'd'.
Returns
boolean... isDown
keyIsUp

Checks to see if one or more keys are currently up.


function keyIsUp ( MOAIKeyboardSensor self, ... )

Parameters
MOAIKeyboardSensorself
...keys Keys to be checked against the input table. Each key can be specified using a MOAIKeyboardSensor.* constant or the corresponding string. Multiple strings can be combined: 'wasd' is equivalent to 'w', 'a', 's', 'd'.
Returns
boolean... isUp
keyUp

Checks to see if one or more keys were released during the last iteration.


function keyUp ( MOAIKeyboardSensor self, ... )

Parameters
MOAIKeyboardSensorself
...keys Keys to be checked against the input table. Each key can be specified using a MOAIKeyboardSensor.* constant or the corresponding string. Multiple strings can be combined: 'wasd' is equivalent to 'w', 'a', 's', 'd'.
Returns
boolean... up
setCallback

This method has been deprecated. Use setKeyCallback instead.


function setCallback ( MOAIKeyboardSensor self [, function callback ] )

Parameters
MOAIKeyboardSensorself
functioncallback Optional. A callback function with the signature "void callback(number keyCode, bool down)". Default value is nil.
Returns
nil
setCharCallback

Sets or clears the callback to be issued when a character is typed.


function setCharCallback ( MOAIKeyboardSensor self [, function callback ] )

Parameters
MOAIKeyboardSensorself
functioncallback Optional. A callback function with the signature "void callback(string character)". Note that for non-ASCII characters, the string argument will be a multibyte UTF-8 character. Default value is nil.
Returns
nil
setEditCallback

Sets or clears the callback to be issued when a character is editing.


function setEditCallback ( MOAIKeyboardSensor self [, function callback ] )

Parameters
MOAIKeyboardSensorself
functioncallback Optional. A callback function with the signature "void callback(string text, number start, number length)". Note that for non-ASCII characters, the string argument will be a multibyte UTF-8 character. Default value is nil.
Returns
nil
setKeyCallback

Sets or clears the callback to be issued when a key is pressed or released.


function setKeyCallback ( MOAIKeyboardSensor self [, function callback ] )

Parameters
MOAIKeyboardSensorself
functioncallback Optional. A callback function with the signature "void callback(number keyCode, bool down)". Default value is nil.
Returns
nil