read into an array

Hello, I am new at this. I am having trouble reading into an array. This code just puts the number i press into the array 4 times instead of stepping through. Please help.

#include <LiquidCrystal_I2C.h>
#include <Wire.h>
#include <Keypad.h>
#include <Key.h>

// definitions for the lcd
#define lcdSDAPin A4
#define lcdSCLPin A5
#define lcdAddress 0x27
#define lcdColumns 20
#define lcdRows 4

// Definitions for the 4x4 matrix
#define Row1Pin 7
#define Row2Pin 8
#define Row3Pin 9
#define Row4Pin 10
#define Col1Pin 6
#define Col2Pin 5
#define Col3Pin 4
#define Col4Pin 3

#define pinLength 5

const byte ROWS = 4; //Four Rows
const byte COLS = 4; //Four Columns 4 x 4 matrix

String pinNumSet;
String pinNumEnter;
String masterPin = “1234”;
char key;
char data[pinLength];
char master[pinLength] = “1234”;
byte dataCount = 0;
byte masterCount = 0;

// Define the keymap for the keypad
char keys[ROWS][COLS] = {
{‘1’, ‘2’, ‘3’, ‘A’},
{‘4’, ‘5’, ‘6’, ‘B’},
{‘7’, ‘8’, ‘9’, ‘C’},
{’*’, ‘0’, ‘#’, ‘D’}
};
byte rowPins[ROWS] = {Row1Pin, Row2Pin, Row3Pin, Row4Pin}; // connect to the row pinouts of the keyboard
byte colPins[COLS] = {Col1Pin, Col2Pin, Col3Pin, Col4Pin,}; // connect to the columns pinouts of the keyboard

// Initialize the keypad object
Keypad keypad = Keypad(makeKeymap(keys), rowPins, colPins, ROWS, COLS);
// Set the pins for the I2C
LiquidCrystal_I2C lcd(lcdAddress, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);

void setup() {
lcd.begin(lcdColumns, lcdRows);
lcd.backlight();
lcd.clear();
keypad.setDebounceTime(100);
keypad.setHoldTime(1500);

// keypad.addEventListener(keyPressed);
}

void loop() {
char key = keypad.getKey();
lcd.setCursor(0, 0);
lcd.print (“Set Pin Number”);
lcd.setCursor(0,1);

pinNumSet = pinNumb();
lcd.print(pinNumSet);
}

String pinNumb()
{
key = keypad.getKey();
if (key) {
for (int i=0; i<= 3; i++) {
data = key;

I think you want this:

...
for( int i = 0; i <= 3; i++)    // loop 4 times
{
    while( !(key = keypad.getKey()));    // keep reading until a nonzero key is obtained.
    data[ i ] = key;                              // store the key into the data array at the location pointed to by i
    delay( 200 );                                 // wait 200 ms for ???
}
...