Using a button as a switch to call a function

Hi
Please could some one help me clear up any misconceptions i may have.
i'm trying to understand the concept of using a push button as a switch. I can find many examples of holding down a push button and the LED turns "on" or "off", but i cant find any examples of the following scenario

  1. push the push button down and release it, and the LED turns "on" and stays "on"
  2. push the push button down a second time and release it, and the LED turns "off" and stays "off"
    Please could some body help me grasp this concept and or even perhaps show me by example code.
    i would be very gratefull
    Thank you,

regards
Jason

but i cant find any examples of the following scenario

You haven't looked vary hard, then.

Why don't you try something? You know how to read a switch state, right?

You know how to determine that the switch is pressed now, but was not pressed last time, or is now pressed now, but was last time. If not, look at the state change detect example.

If the switch is pressed, toggle the state of the LED pin -

ledState = !ledState;

Independently, apply the ledState to the LED pin.

StateChangeDetection example that comes with the Arduino software.

thanks Guys for pointing me in the right direction