pdf-icon

Button

M5Capsule keystroke input related APIs and case programs.

Note:
Include M5Capsule.update() function in the main loop to read state updates and minimize blocking, otherwise the state of key changes may not be retrieved in time.

Example

#include "M5Capsule.h"

void setup() {
    auto cfg = M5.config();
    M5Capsule.begin(cfg);
}

void loop() {
    M5Capsule.update();
    if (M5Capsule.BtnA.wasPressed()) {
        Serial.println("wasPressed");
    }
}

API

M5Capsule library is based on the M5Unified library, the key part uses the Button_Class in the M5Unified library, for more key related APIs you can refer to the following document:

On This Page