Skip to content

Instantly share code, notes, and snippets.

@mschmitt
Created February 1, 2013 07:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mschmitt/4689854 to your computer and use it in GitHub Desktop.
Save mschmitt/4689854 to your computer and use it in GitHub Desktop.
Arduino Leonardo: Send key when a button is pressed.
// Arduino Leonardo: Send key when a button is pressed.
void setup() {
pinMode(12, INPUT_PULLUP);
Keyboard.begin();
}
void loop() {
//if the button is pressed
if(digitalRead(12)==LOW){
// e.g. Apple's CMD key
// Keyboard.press(KEY_LEFT_GUI);
Keyboard.press(KEY_F5);
delay(100);
Keyboard.releaseAll();
delay(200);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment