How to use event.KeyCode

Trying to test out my controls here, but I keep getting weird error messages. This code is just to test to see if I'm doing it write, to see if when I press the x-button, and a character is under the object, they will send out a ray cast that will hit the object, and make it drop by -1000.

Here's my code:

var hit : RaycastHit;
var keyCode : KeyCode;

function Update () {

if (EventType.KeyDown.X){
    if (Physics.Raycast (transform.position, new Vector3(0,1,0), hit, 7) ){
        if (hit.collider.gameObject.tag=="switch") {
            transform.position.y (gameObject.tag=="switch")==-1000;


Once I can figure out how to USE these things, then I can actually go about making scripts for my individual guys (I have two guys on the same screen) to make them work properly, EG: move using different sets of controls.

Looks like you're trying to mix OnGUI code into an Update function. Use the Input class in Update.