I2C Master send reset command to the slave counter
void receiveEvent (int howMany)
  {

  command = Wire.read ();  // remember command for when we get request
  //Serial.println(command);
  switch (command)
     {
     case CMD_WRITE_D2:  
     Serial.println("comando 5 ricevuto");     
     char cmdrst=Wire.read();
     delay(100);        
     Serial.println (cmdrst);
     break;
    }
} // end of receiveEvent



Don't do serial prints inside an interrupt service routine (ISR). That is, not here. 
Don't do delay inside an ISR.




  if (key !='A')  
  {


I would be checking for NO_KEY first, otherwise you will assume that no key press is not 'A' and be doing that transmission to the slave a lot.