[NEW UNITY USER] Question about enabling then quickly disabling object after key press.

Hello, I need help with a very small piece of code. I have an object that isn’t set active. I’d like it so when space is pressed the object is set active, then after 0.5- 1 second turns off. Can anyone help?

float timer;

void Update()
if(timer > 0)
timer -= time.deltatime;

if (timer <= 0)

if (Input.getkey("space))
timer = 1f;