4x4 keypad problem

Good morning all,

i'm using the "classic" 4x4 keypad folloing this circuit

.
The goal of the project is to get 4 numbers from the keypad and store it in an array.

My first code attempt is this.

int thresholds[16]={2,77,144,202,244,290,311,368,394,424,452,477,496,518,538,556};
char keypad[16] ={'1', '2' ,'3','A', '4' ,'5' ,'6' , 'B' , '7' , '8' , '9' , 'C' , '*' , '0' , '#' , 'D'};
char key;
void setup() {
 Serial.begin(9600);
}

void loop() {
 int value = analogRead(A0);
 
 for(int i =0; i <16; i++)
 {
  if(abs(value - thresholds[i])< 5)
  {
    key = keypad[i];
    Serial.println(key);

    while(analogRead(A0) < 1000)
    {
      delay(100);
    }
    
  }
 }

}

this worked just fine , but how can i store the values to a global array .

if(abs(value - thresholds[i])< 5)
  {
    key = keypad[i];
    Serial.println(key);
    someArray[someIndex] = key;

Where someArray is the name of your global array and someIndex is the slot in the array you wan to put the current key in.