Get the current pressed key value. If multiple keys are pressed, return the first one.
#include <Wire.h>
namespace {
#if defined(ESP32)
constexpr gpio_num_t kI2cPinSda = GPIO_NUM_21;
constexpr gpio_num_t kI2cPinScl = GPIO_NUM_22;
#endif
}
void setup() {
Serial.begin(115200);
#if defined(ESP32)
Wire.begin(kI2cPinSda, kI2cPinScl);
#else
Wire.begin();
#endif
const auto result = g_matrix_keyboard.Initialize();
Serial.println(F("matrix keyboard initialization successful"));
} else {
Serial.print(F("Error: matrix keyboard initialization failed: "));
Serial.println(static_cast<uint32_t>(result));
while (true);
}
}
void loop() {
g_matrix_keyboard.Tick();
char key_value = g_matrix_keyboard.GetCurrentPressedKey();
if (key_value != '\0') {
Serial.print("Current pressed key: ");
Serial.println(key_value);
}
}
MatrixKeyboard is a driver class for the Matrix Keyboard module.
static constexpr uint8_t kDefaultI2cAddress
Default I2C address.