You can use a struct to define which keys need to be pressed when you press a key on the matrix. The below struct allows for a normal key and two modifiers (e.g. ctrl, alt).
// include keyboard functionality
#include <Keyboard.h>
// macro to calculate number of elements in an array
#define NUMELEMENTS(x) (sizeof(x) / sizeof(x[0]))
// struct for key and modifiers
struct KEY
{
 const uint8_t key;
 const uint8_t mod1;
 const uint8_t mod2;
};
In the above, I've also included a macro to count the number of elements in an array.
Next you can declare an array of those structs, one for each key of the keypad
KEY keys[] =
{
 {KEY_ESC, KEY_LEFT_CTRL, 0}, // invoke start menu
 {'v', KEY_LEFT_CTRL, 0},   // paste
};
Next you can write a function to send the keys; the below function takes a number as the index in the keys array.
/*
 send keys (e.g. <n>, <ctrl><v>, <ctrl><esc>) to PC
 In:
  index indicating which key combination to send
*/
void pressKey(uint8_t index)
{
 // safety precaution; connect A5 to GND to enable HID functionality
 if (digitalRead(A5) == HIGH)
 {
  Serial.println("HID functionality disabled");
  return;
 }
 // check if a valid index was passed
 if(index >= NUMELEMENTS(keys))
 {
  Serial.println("Invalid index");
  return;
 }
 if (keys[index].mod1 != 0)
 {
  Keyboard.press(keys[index].mod1);
 }
 if (keys[index].mod2 != 0)
 {
  Keyboard.press(keys[index].mod2);
 }
 Keyboard.press(keys[index].key);
 delay(100);
 Keyboard.releaseAll();
}
The code first checks if HID functionality is enabled and next checks (using the earlier defined macro) if it's a valid index. If both conditions are satisfied, it will press the required keys (0 for a modifier indicates that you will not send a modifier) and after a little while it will release the keys.
Next you can write your setup() and loop(). I've not implemented a keypad, I'll leave that to you; if you have a simple keypad with numbers 0..9, you can simply subtract '0' from the key that you read from the keypad and use that as the index.
void setup()
{
 Serial.begin(57600);
 while (!Serial);
 // A5 used to enable HID functionality
 pinMode(A5, INPUT_PULLUP);
Â
 Keyboard.begin();
}
void loop()
{
 pressKey(0);
 delay(1000);
}
The above code will send every second opening and closing the start menu on a Windows system if you have wired A5 to ground.
NOTE
You need a board with native USB (e.g. Leonardo) or you need to hack an Uno or Mega (possibly needs some modificcations of the code, no idea). Tested on a Leonardo.