I find myself often typing in the same links when answering forum questions, and wanted to automate the process a bit.
Example: http://www.gammon.com.au/interrupts
Previously I had a list of them in one place (on a Stickies document on the Mac) but still had to switch apps, highlight, copy, switch back, paste.
Then with the Leonardo and its ability to emulate a keyboard I saw an opportunity. Here:
A 16-key keypad is hooked up to the Leonardo, and when a key is pressed it sends a pre-configured text item to the keyboard. Assuming the cursor is on a forum message, the link is now promptly inserted.
Code is simple:
#include <Keypad2.h>
const byte ROWS = 4;
const byte COLS = 4;
char keys[ROWS][COLS] = {
{'1', '2', '3', 'A'},
{'4', '5', '6', 'B'},
{'7', '8', '9', 'C'},
{'*', '0', '#', 'D'},
};
byte rowPins[ROWS] = {6, 7, 8, 9}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {2, 3, 4, 5}; //connect to the column pinouts of the keypad
// Create the Keypad
Keypad kpd = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );
void setup ()
{
// initialize control over the keyboard:
Keyboard.begin();
} // end of setup
void loop ()
{
byte key = kpd.getKey();
if (!key)
return;
switch (key)
{
case '1': Keyboard.println (F("http://www.gammon.com.au/interrupts")); break;
case '2': Keyboard.println (F("http://www.gammon.com.au/i2c")); break;
case '3': Keyboard.println (F("http://www.gammon.com.au/spi")); break;
// and so on ...
} // end of switch
} // end of loop