#include <Keyboard.h>
#include "Adafruit_Keypad.h"

const byte ROWS = 3; // rows
const byte COLS = 3; // columns
//define the symbols on the buttons of the keypads
char keys[ROWS][COLS] = {
  {'1','2','3'},
  {'4','5','6'},
  {'7','8','9'}
};
byte rowPins[ROWS] = {7,8,9}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {4,5,6}; //connect to the column pinouts of the keypad


//initialize an instance of class NewKeypad
Adafruit_Keypad customKeypad = Adafruit_Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS);

void setup() {
  Serial.begin(9600);
  customKeypad.begin();
  Keyboard.begin();
}

void loop() {
  // put your main code here, to run repeatedly:
  customKeypad.tick();

  while(customKeypad.available()){
    keypadEvent e = customKeypad.read();
    Serial.println((char)e.bit.KEY);
    if(e.bit.EVENT == KEY_JUST_RELEASED){
        switch((char)e.bit.KEY){
          case '1' :{ //for eagle cad
            Keyboard.press(KEY_LEFT_CTRL);
            Keyboard.press(KEY_LEFT_ALT);
            Keyboard.press('e');
            Keyboard.release('e');
            Keyboard.releaseAll();
            break;}
          case '2' :{ //for arduino
            Keyboard.press(KEY_LEFT_CTRL);
            Keyboard.press(KEY_LEFT_ALT);
            Keyboard.press('a');
            Keyboard.release('a');
            Keyboard.releaseAll();
            break;}
          case '3' :{ //for fusion 360
            Keyboard.press(KEY_LEFT_CTRL);
            Keyboard.press(KEY_LEFT_ALT);
            Keyboard.press('f');
            Keyboard.release('f');
            Keyboard.releaseAll();
            break;}
          case '4' :{ //youtube
            Keyboard.press(KEY_LEFT_CTRL);
            Keyboard.press(KEY_LEFT_ALT);
            Keyboard.press('y');
            Keyboard.release('y');
            Keyboard.releaseAll();
            break;}
          case '5' :{//for instructables
            Keyboard.press(KEY_LEFT_CTRL);
            Keyboard.press(KEY_LEFT_ALT);
            Keyboard.press('i');
            Keyboard.release('i');
            Keyboard.releaseAll();
            break;}
          case '6' :{//for emoji
            Keyboard.press(KEY_LEFT_GUI);
            Keyboard.press('.');
            Keyboard.release('.');
            Keyboard.releaseAll();
            break;}
          case '7' :{//for chrome
            Keyboard.press(KEY_LEFT_CTRL);
            Keyboard.press(KEY_LEFT_ALT);
            Keyboard.press('c');
            Keyboard.release('c');
            Keyboard.releaseAll();
            break;}
          case '8' :{ //word
            Keyboard.press(KEY_LEFT_CTRL);
            Keyboard.press(KEY_LEFT_ALT);
            Keyboard.press('w');
            Keyboard.release('w');
            Keyboard.releaseAll();
            break;}
          case '9' :{ //inkscape
            Keyboard.press(KEY_LEFT_CTRL);
            Keyboard.press(KEY_LEFT_ALT);
            Keyboard.press('s');
            Keyboard.release('s');
            Keyboard.releaseAll();
            break;}
            }
        }
      };
  delay(10);
}
