Hello,
I recently got a Arduino Leonardo for a personal project, where a keyboard sustain pedal is used as the shift key on the keyboard, so that I can capitalize with my foot. I tested it, and it looks like I can only control the Arduino's virtual keyboard. When I write Keyboard.press(KEY_LEFT_SHIFT);
, it won't capitalize any keystrokes from my MacBook keyboard, but if I run Keyboard.write('a');
while it still has shift on, it will capitalize that 'a'. Is there any way to press the shift key as if it were on the MacBook keyboard, rather than only applying the shift to the Arduino keyboard?
Thanks in advance,
Garrett M.
Here is my code (in its current, nonworking state), if needed:
int lPin;
int btnPin;
char shiftKey;
void setup() {
lPin = 13;
btnPin = 1;
shiftKey = 129;
pinMode(lPin, OUTPUT);
pinMode(btnPin, INPUT);
Serial.begin(9600);
Keyboard.begin();
}
void loop() {
delay(100);
Serial.println(analogRead(btnPin));
if (analogRead(btnPin) >= 1000) {
Keyboard.press(shiftKey);
Keyboard.write('a');
digitalWrite(lPin, HIGH);
} else {
Keyboard.release(shiftKey);
digitalWrite(lPin, LOW);
}
}