Object appear and disappear on command

How can i set it so if i press 1 a object appears and if i press 1 again it leaves.

K here what i have so far.

function Update () {
    if (Input.GetKeyDown ("1"))
      renderer.enabled = !renderer.enabled;
    if (Input.GetKeyDown ("1"))
       renderer.disabled = !renderer.disabled;
 }

like this?

Poll Input.GetKeyDown every frame, see documentation here:

http://unity3d.com/support/documentation/ScriptReference/Input.GetKeyDown.html

Then when it returns true, set the renderer of the object to enabled/disabled, see documentation here:

http://unity3d.com/support/documentation/ScriptReference/Renderer-enabled.html

Here's an example of something that could work in your case:

function Update () {
    if(Input.GetKeyDown("1"))
        renderer.enabled = !renderer.enabled;
}