Trying to adapt keypad library as a single row of buttons

I'm trying to use a keypad library to create a simon puzzle, I had previously made a sketch for a 3x3 keypad for a simon game and got it working. I want to change it to a a single row of numbered buttons. I tried chaning the pins to duplicates of themselves. so the row and column have the same pin which would be a single button. When the code starts the serial monitor outputs
" Locked!
Matched Key=1 at position=0"

then when i touch 5V to pin3 it says

" 1Wrong key
Matched Key=1 at position=0"

Here is my modified code

#include <Keypad.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x26,16,2);  // set the LCD address to 0x3F for a 16 chars and 2 line display

// Define the states for the lock state machine
#define LOCKED 2
#define UNLOCKED 0

// State Variables:   Initialize to the locked state
int LockState = LOCKED;
long StartTime = 0;
int position = 0;

// Define your password key sequence here
//char* secretCode = "123456789";
char* secretCode = "123456789";

// Keypad key matrix:
const byte rows = 9; 
const byte cols = 9; 
char keys[rows][cols] = {{'1','2','3','4','5','6','7','8','9'},{'1','2','3','4','5','6','7','8','9'}};


// Keypad pin definitions
byte rowPins[rows] = {3,4,5,6,7,8,9,10,11}; 
byte colPins[cols] = {3,4,5,6,7,8,9,10,11}; 

// Instantiate the keypad
Keypad keypad = Keypad(makeKeymap(keys), rowPins, colPins, rows, cols);


void setup()                    
{
  lcd.init();
  lcd.clear();         
  lcd.backlight();      // Make sure backlight is on
  lcd.setCursor(0,0);   //Set cursor to character 2 on line 0
  lcd.print("LCD TEST");

   Serial.begin(9600);
   
   setLockState(LOCKED); 
 
   lcd.print("Simon begin");
   lcd.clear();
}

void loop()                    
{
    if (LockState == LOCKED)
    {  
        lcd.clear();
        lcd.setCursor(0,0);   //Set cursor to character 2 on line 0
        lcd.print("LOCKED 123456789");
    }
    else if (LockState == UNLOCKED)
    {  
        lcd.clear();
        lcd.setCursor(0,0);   //Set cursor to character 2 on line 0
        lcd.print("UNLOCKED 123456789");
    }

   // Run the state machine:
   // Locked State - Monitor keypad for valid Password code entry
   if (LockState == LOCKED)
   {
      char key = keypad.getKey();

      if (key == '*' || key == '#')
      {
         position = 0;
         setLockState(LOCKED);
      }
      if (key != 0)
      {
         if (key == secretCode[position])  // Valid key in Password sequence
         {
            Serial.print("Matched Key=");   
            Serial.print(key);   
            Serial.print(" at position=");   
            Serial.println(position);              
            position ++;
         }
         else  // Invalid key - start all over again
         {
            Serial.print(key ); 
            Serial.println("Wrong key");   
              lcd.clear();
              lcd.setCursor(0,0);   //Set cursor to character 2 on line 0
              lcd.print("Wrong key");
              lcd.setCursor(0,1);   //Set cursor to character 2 on line 0
              lcd.print("Key entered ");
              lcd.setCursor(13,1);   //Set cursor to character 2 on line 0
              lcd.print(key);
            position = 0;
         }
      }

      if (position == 9)  // Password successfully entered - advance state
      {
         setLockState(UNLOCKED);
         position = 0;
      }
      delay(100);
   }

   // UNLOCKED state - hold the solenoid open for a limited time
   else if (LockState == UNLOCKED)
   { 
      for (int i = 0; i < 30; i++)
      {
         // Flash the led to indicate the lock is open
         //digitalWrite(LedPin, LOW);
         delay(50);
         //digitalWrite(LedPin, HIGH);
         delay(50);
      }
      setLockState (LOCKED);  // Time-out - go back to the locked state.
   }
}

// Set the state and the time of the state change
void setLockState(int state)
{
   LockState = state;
   StartTime = millis ();
   if (state == LOCKED)
   {
      Serial.println("Locked!");
      lcd.print("locked! 123456789");  
   } 
   else if (state == UNLOCKED)
   {
      Serial.println("Unlocked!");
      lcd.print("Unlocked! 123456789"); 
   }
}
[Maze V1B1.ino|attachment](upload://pgTdwOUXeikNCDO7YQHqxCtt2KY.ino) (3.5 KB)

Update: New issue. How do i check a digit that is 2 digits long ? Like the number 10 how do i make it read 10 as 10 and not as 1 and then 0 ?

I'm not sure if the file i uploaded worked. Here is the original simon game sketch

#include <Keypad.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27,16,2);  // set the LCD address to 0x3F for a 16 chars and 2 line display

// Define the states for the lock state machine
#define LOCKED 2
#define UNLOCKED 0

// State Variables:   Initialize to the locked state
int LockState = LOCKED;
long StartTime = 0;
int position = 0;

// Define your password key sequence here
//char* secretCode = "123456789";
char* secretCode = "628751943";

// Keypad key matrix:
const byte rows = 3; 
const byte cols = 3; 
char keys[rows][cols] = 
{
   {'7','8','9'},
   {'4','5','6'},
   {'1','2','3'}
};


// Keypad pin definitions
byte rowPins[rows] = {2, 3, 4}; 
byte colPins[cols] = {5, 6, 7};  

// Instantiate the keypad
Keypad keypad = Keypad(makeKeymap(keys), rowPins, colPins, rows, cols);

void setup()                    
{
  lcd.init();
  lcd.clear();         
  lcd.backlight();      // Make sure backlight is on
  lcd.setCursor(0,0);   //Set cursor to character 2 on line 0
  lcd.print("LCD TEST");

   Serial.begin(9600);
   
   setLockState(LOCKED); 
 
   lcd.print("Simon begin");
   lcd.clear();

}

void loop()                    
{
    if (LockState == LOCKED)
    {  
        lcd.clear();
        lcd.setCursor(0,0);   //Set cursor to character 2 on line 0
        lcd.print("LOCKED 628751943");
    }
    else if (LockState == UNLOCKED)
    {  
        lcd.clear();
        lcd.setCursor(0,0);   //Set cursor to character 2 on line 0
        lcd.print("UNLOCKED 628751943");
    }

   // Run the state machine:
   // Locked State - Monitor keypad for valid Password code entry
   if (LockState == LOCKED)
   {
      char key = keypad.getKey();

      if (key == '*' || key == '#')
      {
         position = 0;
         setLockState(LOCKED);
      }
      if (key != 0)
      {
         if (key == secretCode[position])  // Valid key in Password sequence
         {
            Serial.print("Matched Key=");   
            Serial.print(key);   
            Serial.print(" at position=");   
            Serial.println(position);             
            position ++;
         }
         else  // Invalid key - start all over again
         {
            Serial.print(key ); 
            Serial.println("Wrong key");   
              lcd.clear();
              lcd.setCursor(0,0);   //Set cursor to character 2 on line 0
              lcd.print("Wrong key");
              lcd.setCursor(0,1);   //Set cursor to character 2 on line 0
              lcd.print("Key entered ");
              lcd.setCursor(13,1);   //Set cursor to character 2 on line 0
              lcd.print(key);
            position = 0;
         }
      }

      if (position == 9)  // Password successfully entered - advance state
      {
         setLockState(UNLOCKED);
         position = 0;
      }
      delay(100);
   }

   // UNLOCKED state - hold the solenoid open for a limited time
   else if (LockState == UNLOCKED)
   { 
      for (int i = 0; i < 30; i++)
      {
         // Flash the led to indicate the lock is open
         //digitalWrite(LedPin, LOW);
         delay(50);
         //digitalWrite(LedPin, HIGH);
         delay(50);
      }
      setLockState (LOCKED);  // Time-out - go back to the locked state.
   }
}

// Set the state and the time of the state change
void setLockState(int state)
{
   LockState = state;
   StartTime = millis ();
   if (state == LOCKED)
   {
      Serial.println("Locked!");
      lcd.print("locked! 628751943");  
   } 
   else if (state == UNLOCKED)
   {
      Serial.println("Unlocked!");
      lcd.print("Unlocked! 628751943"); 
   }
}

If you want a 1x9 matrix, use a 1x9 matrix. You will need 1 row pin and 9 column pins. Ten pins total.

// Keypad key matrix:
const byte rows = 1; 
const byte cols = 9; 
char keys[rows][cols] = {{'1','2','3','4','5','6','7','8','9'}};


// Keypad pin definitions
byte rowPins[rows] = {12}; 
byte colPins[cols] = {3,4,5,6,7,8,9,10,11}; 

Thank you! That change worked. I'm having another issue though. How do i check a digit that is 2 digits long ? Like the number 10 how do i make it read 10 as 10 and not as 1 and then 0 ? Do you have an idea on how to implement this?

Yes.
Start with:
number = 0;
When a digit key is pressed:
number = number * 10 + digitCharacter - '0';
When the number is compete, use it and set number back to 0.

How do you enter '10' when you have no '0' key?

How do you know if '1' is the whole number or if a second digit might arrive? Usually, that is done with some kind of 'Enter' key to signal the end of the digits.

Thank you for the response. I run into another problem. I can only have 16 values for
byte rowPins[rows] = {2, 3, 4};
byte colPins[cols] = {5, 6, 7};
how would i expand it so that i can have more 16 buttons in a row? the library needs them to be bytes. could i change it to int in the library files and then it would work?

You can expand the library from 16-coumn rows to 32-column rows by changing the line
uint bitMap[MAPSIZE]; // 10 row x 16 column array of bits. Except Due which has 32 columns.
in Keyad.h to
ulong bitMap[MAPSIZE]; // 10 row x 32 column array of bits.