Hello Gophers!

Today I will write about how to build a very simple little matrix keyboard that
can be used to make your life easier. Especially when using software that makes
use of a lot of keyboard shortcuts. I use this keyboard for OBS studio to select
scenes.

You will need the following:


1. Matrix keyboard.
  Example: https://www.aliexpress.com/item/4000873237364.html

2. Arduino Pro Micro ATMega32U4.
  Example: https://www.aliexpress.com/item/32952028063.html

3. Micro-USB  to USB-A cable (1 meter should be enough)

4. Little plastic box to put it all in

You start by glueing the Arduino to the back of the keypad with a little hotglue
Then you connect the column lines to Arduino pins 15,14,16 and 10. You connect
the row lines to pins 9,8,7 and 6. It all is laid out symetrically, no lines
will cross each other. This makes for a nice cable layout.

Then you load up the following code in Arduino: (copy and put in a file with
the .ino extension)

[code]
       #include <Keypad.h>
       #include <Keyboard.h>

       char keys[4][4]={
        {'1','2','3','A'},
        {'4','5','6','B'},
        {'7','8','9','C'},
        {'*','0','#','D'}};

       byte rowPin[4]={9,8,7,6};
       byte colPin[4]={15,14,16,10};

       Keypad keypad=Keypad(makeKeymap(keys),rowPin,colPin,4,4);

       void setup()
       {
          Keyboard.begin();
       }

       void loop()
       {
        char pressed=keypad.getKey();
        if(pressed)
        {
             Keyboard.press(KEY_LEFT_CTRL);
             Keyboard.press(KEY_LEFT_ALT);
             Keyboard.press(KEY_LEFT_SHIFT);
             //Keyboard.press(KEY_LEFT_GUI);
             Keyboard.press(pressed);
             delay(10);
             Keyboard.releaseAll();
        }
       }
[/code]

This will read the keypad and put it out with the modifier keys Ctrl, Alt and Shift
activated. Pushing 1 leads therefore to a keyboard event that fires Ctrl-Alt-
Shift-1. You can change to code around to get other combinations.

The keypad library used is in the Arduino repositories. Info can be found here:

https://playground.arduino.cc/Code/Keypad/

I found this easy to build, and very handy to use. Enjoy!

Cheers,

Fripster