One pin of the keypad should be common to all. If you put circuit ground to it, and pull the other pins high through a resistor, you will see each button press will cause the pin associated with the button to go from a logic high to a low - say +5 volts to 0 volts. Use the same voltage as the 8051 is running on.
Wire the four active pins of the keypad to four input pins on the 8051 and there you are.