// Play with Teensy 3 USB keyboard
// Type AbC on first line (works)
// Type the copyright symbol on the second line (fails)
int led = 13;
int keypress(uint8_t key, uint8_t modifier)
{
int r;
keyboard_modifier_keys = modifier;
keyboard_keys[0] = key;
keyboard_keys[1] = 0;
keyboard_keys[2] = 0;
keyboard_keys[3] = 0;
keyboard_keys[4] = 0;
keyboard_keys[5] = 0;
return usb_keyboard_send();
}
int key_release_all(void)
{
delay(1);
keyboard_modifier_keys = 0;
keyboard_keys[0] = 0;
keyboard_keys[1] = 0;
keyboard_keys[2] = 0;
keyboard_keys[3] = 0;
keyboard_keys[4] = 0;
keyboard_keys[5] = 0;
return usb_keyboard_send();
}
// the setup routine runs once when you press reset:
void setup() {
pinMode(led, OUTPUT);
// flash led for 10 seconds
for (int i=0; i < 10; i++) {
digitalWrite(led, HIGH);
delay(500);
digitalWrite(led, LOW);
delay(500);
}
usb_keyboard_press(KEY_A,MODIFIERKEY_SHIFT);
usb_keyboard_press(KEY_B,0);
usb_keyboard_press(KEY_C,MODIFIERKEY_SHIFT);
usb_keyboard_press(KEY_ENTER,0);
// Use my modified key press code to try to generate
// copyright symbol
// light up the LED if this first one fails
if(keypress(0,MODIFIERKEY_LEFT_ALT) < 0)digitalWrite(led, HIGH);
keypress(KEYPAD_0,MODIFIERKEY_LEFT_ALT);
keypress(KEYPAD_1,MODIFIERKEY_LEFT_ALT);
keypress(KEYPAD_6,MODIFIERKEY_LEFT_ALT);
keypress(KEYPAD_9,MODIFIERKEY_LEFT_ALT);
key_release_all();
keypress(KEY_ENTER,0);
key_release_all();
}
// the loop routine runs over and over again forever:
void loop() {
}