#include const int switchPin = 2; // Change this to match the pin you've connected the toggle switch to const int debounceDelay = 50; // milliseconds int lastSwitchState = HIGH; // Initial state of the switch (assumed to be HIGH) int currentSwitchState; void setup() { pinMode(switchPin, INPUT_PULLUP); Serial.begin(9600); Keyboard.begin(); } void loop() { currentSwitchState = digitalRead(switchPin); if (currentSwitchState != lastSwitchState) { delay(debounceDelay); // Debounce if (digitalRead(switchPin) != lastSwitchState) { if (currentSwitchState == LOW) { triggerCtrlE(); } else { triggerCtrlE(); } } } lastSwitchState = currentSwitchState; } void triggerCtrlE() { for (int i = 0; i < 3; i++) { Keyboard.press(KEY_LEFT_CTRL); Keyboard.press('e'); Keyboard.releaseAll(); delay(50); } }