using a variable to index an array I'm using the keypad library to return a number 1-9. (im fairly sure this returns an int)
I have an array (data) showing the state of each button press.
so i would like the number returned by the keypad (key) to be the index number that gets edited from 0 to 1 and from 1 to 0.
    //REMOTE KEYPAD TO CONTROL OUTPUTS OVER SERIAL

#include &lt;Keypad.h&gt;

const byte ROWS = 4; //four rows
const byte COLS = 4; //three columns
char keys[ROWS][COLS] = {
  {'1', '2', '3'},
  {'4', '5', '6'},
  {'7', '8', '9'},

};
byte rowPins[ROWS] = {5, 4, 3, 2}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {9, 8, 7, 6}; //connect to the column pinouts of the keypad

Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );


int iAm = 1;                                    //this is device number 1
float checkSum = 0.00;                          //check sum to send as serial
float voltage = 5.26;                           //system voltage
bool data[8] {0, 0, 0, 0, 0, 0, 0, 0, 0};       //keypad output call

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


void loop() {

  int key = keypad.getKey();
  
  
  if (key) {
        data[key] = 1;
    
    //checkSum = voltage * (iAm + data[0] + data[1] + data[2] + data[3] + data[4] + data[5] + data[6] + data[7] + data[8] + data[9]); 
    //Serial.print(iAm);
    //Serial.print(&quot;/&quot;);
    Serial.print(data[1]);
    Serial.print(&quot;/&quot;);
    Serial.print(data[2]);
    Serial.print(&quot;/&quot;);
    Serial.print(data[3]);
    Serial.print(&quot;/&quot;);
    Serial.print(data[4]);
    Serial.print(&quot;/&quot;);
    Serial.print(data[5]);
    Serial.print(&quot;/&quot;);
    Serial.print(data[6]);
    Serial.print(&quot;/&quot;);
    Serial.print(data[7]);
    Serial.print(&quot;/&quot;);
    Serial.print(data[8]);
    Serial.print(&quot;/&quot;);
    Serial.print(data[9]);
    Serial.print(&quot;/&quot;);
    Serial.print(voltage);
    Serial.println(&quot;/&quot;);
    //Serial.println(checkSum);
      
  }
    
}

i can edit the index location by typing data[1] = 1 but not as a variable so i suspect an index cant be addressed as int? but i don't know what it should be addressed as or how to change it to that.
not going to pretend i understand why all my keypad numbers are 48 higher than the number printed on the keypad but:
int key2 = key -48;

works