Skip to content

Instantly share code, notes, and snippets.

@bricklife
Created May 27, 2020 04:53
Show Gist options
  • Save bricklife/4fc7d0055697b74bfc753e58f79edc2e to your computer and use it in GitHub Desktop.
Save bricklife/4fc7d0055697b74bfc753e58f79edc2e to your computer and use it in GitHub Desktop.
#include <BleKeyboard.h> // https://github.com/T-vK/ESP32-BLE-Keyboard
BleKeyboard bleKeyboard;
bool pressing = false;
void setup() {
pinMode(25, INPUT_PULLUP); // A1 pin
bleKeyboard.begin();
}
void loop() {
if (bleKeyboard.isConnected()) {
if (digitalRead(25) == LOW && !pressing) {
pressing = true;
bleKeyboard.press(KEY_LEFT_GUI);
bleKeyboard.press('d');
}
if (digitalRead(25) == HIGH && pressing) {
pressing = false;
bleKeyboard.releaseAll();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment