1, 4, 7 keys on 4x4 number matrix pad not working

All other numbers are being recorded when pressed. Here is my code:

/*4x4 Matrix Keypad connected to Arduino
  This code prints the key pressed on the keypad to the serial port*/

#include <Keypad.h>

const byte numRows = 4; //number of rows on the keypad
const byte numCols = 4; //number of columns on the keypad

//keymap defines the key pressed according to the row and columns just as appears on the keypad
char keymap[numRows][numCols] =
{
  {'1', '2', '3', 'A'},
  {'4', '5', '6', 'B'},
  {'7', '8', '9', 'C'},
  {'*', '0', '#', 'D'}
};

//Code that shows the the keypad connections to the arduino terminals
byte rowPins[numRows] = {9, 8, 7, 6}; //Rows 0 to 3
byte colPins[numCols] = {5, 4, 3, 2}; //Columns 0 to 3

//initializes an instance of the Keypad class
Keypad myKeypad = Keypad(makeKeymap(keymap), rowPins, colPins, numRows, numCols);

void setup()
{
  Serial.begin(9600);
}

//If key is pressed, this key is stored in 'keypressed' variable
//If key is not equal to 'NO_KEY', then this key is printed out
//if count=17, then count is reset back to 0 (this means no key is pressed during the whole keypad scan process
void loop()
{
  char keypressed = myKeypad.getKey();
  if (keypressed != NO_KEY)
  {
    Serial.print(keypressed);
  }
}

I re-inserted the cables on both ends, and it still doesn't work.

(deleted)

Looks like a bad connection on pin 5. Does it detect and print the '*'

Pete

Another test is to connect the column pins backward and change the definition of colPins to byte colPins[numCols] = {2, 3, 4, 5};
If the problem changes from column zero (can't read 1,4,7,*) to column 3 (can't read A,B,C,D), there's something wrong with the numeric pad. If you don't need A,B,C,D that will workaround the problem anyway.

Pete

which keypad do you use?

Please excuse for my bad language.
I had exactly the same problem. Nothing worked and i couldnt read out the values. I solved the problem by opening the whole keypad up.( Thats fairly easy. You only have to take a sharp knife and scratch away the little black plastic knobs on the back side)

In my case the problem was, that some traces on the board were only made of carbon. I think the idea behind this was , that this would work somehow as a resistor. But i mesaured it out, and the resistance was simply too high as the arduino could recognize it.
So i scratched out some traces and replaced the missing connections with some wire. I just soldered directly to the board. Now it works like a charm.

!! I do not give any guarantee that this will work. If you try this, you do it at YOUR OWN RISK !!