A lot of incoming midi messeges cause synth

@charnjit - I have had an opportunity to run the keypad exactly how you are using it, and there is no sign of repeated pressed events.

As I had to strip away all the display and MIDI stuff, it is possible I damaged something (fixed, that is), but I am quite good at hacking, my confidence is high.

I suggest you write a simpler sketch that uses only the serial monitor. No display, no MIDI and see if you can get one prssed/released pair per actual keystroke.

I see your code runs through only the active key list filled in by the getKetys() method. I'll file this under I learned something today.

Hacked down sketch
type or paste code here# include <Keypad.h>                   

const uint8_t ROWS = 4;
const uint8_t COLS = 4;

char keys[ROWS][COLS] = {
  { '1', '2', '3', 'A' },
  { '4', '5', '6', 'B' },
  { '7', '8', '9', 'C' },
  { '*', '0', '#', 'D' }
};

uint8_t colPins[COLS] = { 5, 4, 3, 2 }; // Pins connected to C1, C2, C3, C4
uint8_t rowPins[ROWS] = { 9, 8, 7, 6 }; // Pins connected to R1, R2, R3, R4

Keypad kpd = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );

void setup() {
  Serial.begin(115200);
  Serial.println("Hello Keypad Advanced World!\n");
}

void loop() {
  if (kpd.getKeys()) {
    for (int ij = 0; ij < LIST_MAX; ij++) {      
      int mykey = kpd.key[ij].kchar;
      if (( kpd.key[ij].stateChanged ) && (mykey < 128 )&& (mykey > 0 )) 
      {
          switch (kpd.key[ij].kstate) {  
          case PRESSED:
            Serial.print(ij); Serial.print(" pressed "); Serial.println(mykey);
            break;
          
          case RELEASED:
            Serial.print(ij); Serial.print(" released "); Serial.println(mykey);
            break;
          }
      }  
    }
  }   
}

Dunno where else to look, what is your keyboard and how is it wired?

a7