Try adding a delay here:



int getKeyPin(int key){
int p = key/COL_COUNT;
if (p != currentRow){
pinMode(rowPins[currentRow], INPUT);
pinMode(rowPins[p], OUTPUT);
...