left_button

The left button on the hub

Example

var hub = new serviceSPIKE.PrimeHub();
var left_button = hub.left_button;
// do something with left_button

Methods

static wait_until_pressed(callback)

execute callback after this button is pressed

Parameters:
Name Type Description
callback function

function to run when button is pressed

Example
var hub = new serviceSPIKE.PrimeHub();
var left_button = hub.left_button;
left_button.wait_until_pressed ( function () {
    console.log("left_button was pressed");
})

static wait_until_released(callback)

execute callback after this button is released

Parameters:
Name Type Description
callback function

function to run when button is released

Example
var hub = new serviceSPIKE.PrimeHub();
var left_button = hub.left_button;
left_button.wait_until_released ( function () {
    console.log("left_button was released");
})

static was_pressed() → {boolean}

Tests to see whether the button has been pressed since the last time this method called.

Returns:
boolean -
  • True if was pressed, false otherwise
Example
if (left_button.was_pressed()) {
     console.log("left_button was pressed")
}

static is_pressed() → {boolean}

Tests to see whether the button is pressed

Returns:
boolean -

True if pressed, false otherwise

Example
if (left_button.is_pressed()) {
     console.log("left_button is pressed")
}