We'll be doing on/off stuff with logic bricks!
Fire up the game engine and open up the logic editor.
Select the cube (or any object), add a new property and name it as "toggle".
Set it's type as "Boolean",
this helps us to do the toggle stuff and enable "print debug information" which
helps us to debug the property.
Now add a "Keyboard" sensor if you haven't, a property actuator and connect them. Before running the game, we need to make sure the toggle stuff actually works, so go ahead and enable Show Debug Properties by going to Play -> Show Debug -> Show Debug Properties or by going to Render -> Debug -> Properties.
Now lets trigger our keyboard to see if it works, you'll see your "toggle" property going to TRUE and FALSE.
Now to implement object visibility we're gonna add two property sensors and two visiblity actuators, the first property sensor will be checking the toggle's value, in the field type it as TRUE connect it with the first visibility actuator. For the second prop sensor, type in the field as FALSE and connect it with the second visibility actuator which must have it's visibililty turned off.