How does this N-key-rollover work?
A pull-up resistor is required on both pins 1 and 2. These will weakly pull the output pins high. Additionally A and B are either driven high or low depending on which column you are wanting to scan - driving low enables a column, driving high disabled a column.

If input A say is driven low, and outputs 1 and 2 are pulled weakly high by a resistor, then you basically have a circuit that is nothing more than two push buttons. You can read the values of 1 and 2 to see if the button is pressed or not.

If input B is driven low, you again have two push buttons which can be checked by reading 1 and 2. Again the outputs are weakly driven high by resistors.

By constantly swapping between B and A being driven low, you can read all four buttons using two pins.

The diodes prevent the buttons in column B from being registered if you were to push multiple buttons simultaneously (e.g. pressing all of A1, B1, A2 simultaneously would otherwise pull B2 low).

The reason the pull-up resistors are not shown is that these are typically present internally in the microcontroller used to read the array.