Class buttonListener
buttonListener
Defined in: buttonListener.js.
Constructor Attributes | Constructor Name and Description |
---|---|
An object to listen to input.
|
Field Attributes | Field Name and Description |
---|---|
The user function to call when the input is held.
|
|
The user function to call when the input is pressed / activated
|
|
The user function to call when the input is released.
|
Method Attributes | Method Name and Description |
---|---|
remove()
Removes the button listener from sandboxe.
|
Class Detail
buttonListener()
An object to listen to input. See sandboxe.input.buttonListener.create to instantiate
and enable it.
buttonListener allows you to set up more detailed specific behavior as soon
as an input even is recorded for a frame, allowing you to avoid the classic
"query input every frame pattern".
Example:
// creates the button listener and automatically links it // to start listening for the button. In this case, the space key listener = sandboxe.input.buttonListener.create(sandboxe.key_space); // Sets the message for the press event listener.onPress = function() { sandboxe.console.info('Space was pressed!\n'); } // Sets the message for the hold event listener.onHold = function() { sandboxe.console.info('Space was held!\n'); } // Sets the message for the release event listener.onRelease = function() { sandboxe.console.info('Space was released!\n'); }
Field Detail
onHold
The user function to call when the input is held. It is called
every frame that it is held until it is release.
onPress
The user function to call when the input is pressed / activated
onRelease
The user function to call when the input is released.
Method Detail
remove()
Removes the button listener from sandboxe.