is Pressed

Check if a button is being pressed or not.

input.buttonA.isPressed()

Touch

If your board has pins or pads that work as touch inputs, then your code can use them just like buttons. Instead of saying button A or button B as the input source, use a pin name like pin A1.

if (input.pinA1.isPressed()) {
    console.log("Hey, I feel pressed.");
}

Read about touch sensors and using the pins as touch buttons.

Returns

  • a boolean: true if the button is pressed, false if the button is not pressed

Example

Log a message when button A is pressed.

forever(function() {
    if (input.buttonA.isPressed()) {
        console.log("Button A is pressed")
    }
    pause(300)
})

See also

was pressed, on event

Touch sensors