Sorry for jumping into this thread, but I have also struggled a lot with this and I have now managed to make it work. I have extended it to 5X5 which works as well.
But before I came so far to make it work with Arduino, I have made another solution by modifying an X-KEYS, XK-24.
However, this is an expensive solution, but it is working perfectly. I now have 18 X 18 buttoms spread over 2 layers and because of the two layers, I can reduce the physical size of my foot pedal board.
Well, I did purchased this Arduino Micro Pro for the above purpose and want to make it work anyway.
I would like to make an MIDI pedal with it.
My next challenge would then be, to figure out, how to use the data from the button matrix to use for MIDI.
Please be aware, that I am definitely not any geek into programming! There is probably a much better solution for this, so please take it or leave it. 
The code I have put together, is from reading several forum threads: (Have left out some of the code due to maxium allowed characters)
/*
*/
int j = 1; // integer used in scanning the array designating column number
//2-dimensional array for assigning the buttons and there high and low values
int Button[25][3] = {{1, 876, 880}, // button 1 *1
{2, 764, 768}, // button 2 *2
{3, 668, 672}, // button 3 *3
{4, 604, 608}, // button 4 *4
{5, 568, 572}, // button 5 *5
{6, 527, 531}, // button 6 *6
{7, 484, 488}, // button 7 *7
{8, 444, 448}, // button 8 *8
{9, 415, 419}, // button 9 *9
{10, 397, 401}, // button 10 *A
{11, 357, 361}, // button 11 *B
{12, 336, 340}, // button 12 *C
{13, 316, 320}, // button 13 *D
{14, 301, 305}, // button 14 *E
{15, 292, 296}, // button 15 *F
{16, 275, 279}, // button 16 *G
{17, 262, 266}, // button 17 *H
{18, 250, 254}, // button 18 *I
{19, 240, 244}, // button 19 *J
{20, 234, 238}, // button 20 *K
{21, 227, 231}, // button 21 *L
{22, 219, 223}, // button 22 *M
{23, 210, 214}, // button 23 *N
{24, 203, 207}, // button 24 *O
{25, 199, 203}}; // button 25 *P
int analogpin = 0; // analog pin to read the buttons
int label = 0; // for reporting the button label
int counter = 0; // how many times we have seen new value
long time = 0; // the last time the output pin was sampled
int debounce_count = 50; // number of millis/samples to consider before declaring a debounced input
int current_state = 0; // the debounced input value
int ButtonVal;
int analogPin = 0; // Read serial data connected to analog pin 0
int val = 0; // variable to store the value read for serial read
boolean b1 = false;
boolean b2 = false;
boolean b3 = false;
boolean b4 = false;
boolean b5 = false;
// code left out
long randNumber;
void setup()
{
Keyboard.begin();
Serial.begin(9600); // setup serial
randomSeed(analogRead(1));
randNumber = random(0,2);
}
void loop()
{
val = analogRead(analogPin); // read the input pin
Serial.println(val); // debug value. E.g. 878 for button 1 is like this: {1, 876, 880}, // button 1 *1
static float in = 4.712;
float out;
// If we have gone on to the next millisecond
if (millis() != time)
{
// check analog pin for the button value and save it to ButtonVal
ButtonVal = analogRead(analogpin);
if(ButtonVal == current_state && counter >0)
{
counter--;
}
if(ButtonVal != current_state)
{
counter++;
}
// If ButtonVal has shown the same value for long enough let's switch it
if (counter >= debounce_count)
{
counter = 0;
current_state = ButtonVal;
//Checks which button or button combo has been pressed
if (ButtonVal > 0)
{
ButtonCheck();
}
}
time = millis();
}
}
void ButtonCheck()
{
// loop for scanning the button array.
for(int i = 0; i <= 25; i++)
{
// checks the ButtonVal against the high and low vales in the array
if(ButtonVal >= Button[i][j] && ButtonVal <= Button[i][j+1])
{
// stores the button number to a variable
label = Button[i][0];
Action();
}
}
}
void Action()
{
if(label == 1)
{
b1=true;
b2=false;
b3=false;
b4=false;
b5=false;
b6=false;
b7=false;
b8=false;
b9=false;
b10=false;
b11=false;
b12=false;
b13=false;
b14=false;
b15=false;
b16=false;
b17=false;
b18=false;
b19=false;
b20=false;
b21=false;
b22=false;
b23=false;
b24=false;
b25=false;
Keyboard.print('1');
}
if(label == 2)
{
b1=false;
b2=true;
b3=false;
b4=false;
b5=false;
b6=false;
b7=false;
b8=false;
b9=false;
b10=false;
b11=false;
b12=false;
b13=false;
b14=false;
b15=false;
b16=false;
b17=false;
b18=false;
b19=false;
b20=false;
b21=false;
b22=false;
b23=false;
b24=false;
b25=false;
Keyboard.print('2');
}
if(label == 3)
{
b1=false;
b2=false;
b3=true;
b4=false;
b5=false;
b6=false;
b7=false;
b8=false;
b9=false;
b10=false;
b11=false;
b12=false;
b13=false;
b14=false;
b15=false;
b16=false;
b17=false;
b18=false;
b19=false;
b20=false;
b21=false;
b22=false;
b23=false;
b24=false;
b25=false;
Keyboard.print('3');
}
if(label == 4)
{
b1=false;
b2=false;
b3=false;
b4=true;
b5=false;
b6=false;
b7=false;
b8=false;
b9=false;
b10=false;
b11=false;
b12=false;
b13=false;
b14=false;
b15=false;
b16=false;
b17=false;
b18=false;
b19=false;
b20=false;
b21=false;
b22=false;
b23=false;
b24=false;
b25=false;
Keyboard.print('4');
}
// Code left out!!
}