How to set the 'enabled' bool of a Canvas GameObject in JS

(Unity 4.6 beta 17) I have a GameObject in the hierarchy that is a UI canvas and I want to be able to enable/disable it with the press of a key.

I want it to do the exact same thing as when you make a UI button, go to the “On Click ()” option in the Inspector and choose the canvas, then for the function choose “Canvas” > “bool enabled”.

Please don’t be vague and give me an example script like how to get the game object (correctly to get the canvas) and how to set the boolean.

var myGameObject : GameObject;
var canvasEnabled : boolean;

function Start () {
    myGameObject.GetComponent(Canvas).enabled = canvasEnabled;
}