Again, I don't have a keypad, but see if this works:
#include <Keypad.h>
const byte ROWS = 4; //four rows
const byte COLS = 3; //three columns
char keys[ROWS][COLS] = {
{'1', '2', '3'},
{'4', '5', '6'},
{'7', '8', '9'},
{'*', '0', '#'}
};
byte rowPins[ROWS] = {8, 7, 6, 5}; //connect to the row pinouts of the kpd
byte colPins[COLS] = {4, 3, 2}; //connect to the column pinouts of the kpd
Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );
void setup() {
Serial.begin(9600);
}
void loop() {
char entryStr[12];
char key;
int i = 0;
while (1) {
key = keypad.getKey();
switch (key) {
case '*': // Cancel
Serial.println("");
Serial.println("Canceled");
break;
case '#': // Done
entryStr[i] = '\0';
strcat(entstr, ".mp3");
Serial.print(entstr);
break;
default: // Add a char
entryStr[i++] = key;
break;
}
if (key == '#' || key == '*') { // Start over??
break;
}
}
}
Note the disappearance of memset() and filename and fewer statements on key and i.