How to keep value of input pin locked in?

Hi, I am working on using a push button input to turn on an led, but want to keep the led when i press it once and let go (not hold it), the code I wrote is below. My hookup is led on pin 13 w/ ground, pin7 input pin to pushbutton pin (also has resistor going from 5v to the same pin of pushbutton), gnd to matching pushbutton pin to gnd. It works at the moment but only if you hold it, how could I make it so it stays on when toggled once? my endgoal is to use a push button, press it once and the LED stays on until pressed again (then I will replace the led with a relay for turning things off and on that are high voltage).

int ledPin = 13;
int inputPin = 7;
int logic = 0;

void setup() {
 pinMode(ledPin, OUTPUT);
 pinMode(inputPin, INPUT); 
}


void loop() {
logic = digitalRead(inputPin);
digitalWrite(ledPin, logic);
  
}

The State change detection example in the IDE (Files, Examples, Digital) will show how to do what you wish.

very typical state change example, FYI

think about how the loop() function reacts if you hold down the button.

int ledPin = 13;
int inputPin = 7;
int oldValue;

void setup() 
{
  pinMode(ledPin, OUTPUT);
  pinMode(inputPin, INPUT); 
}

void loop() 
{
  int logic = digitalRead(inputPin);
  if (logic == HIGH)
  {
    if (oldValue == LOW)
    {
      digitalWrite(ledPin, !digitalRead(ledPin));
    }
  }
  oldValue = logic;
}