Arduino Guide
M5Capsule keystroke input related APIs and case programs.
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.#include "M5Capsule.h"
void setup() {
auto cfg = M5.config();
M5Capsule.begin(cfg);
}
void loop() {
M5Capsule.update();
if (M5Capsule.BtnA.wasPressed()) {
Serial.println("wasPressed");
}
}
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: