GetKey is not working...

Hi Guyz…
I am new to unity3d.
I have simple question
In following code GetKey is not at all working…

void Update () 
{
	if(Input.GetKey (KeyCode.Z))
	transform.Translate (speed, 0, 0);
     }

Do I need to register ‘Z’ key somewhere in setting or am I missing something???

-pax

try this instead:

if(Input.GetKey("z"))

Did you define “speed” before the “Update” loop?
Did you put the Script on the right GameObject?

There are 2 things you can do. Either you can drag the Script ON the Object you want to Translate, or you add something to it. If you take the second option, do it like this:

using UnityEngine;
using System.Collections;

public class Translate : MonoBehaviour {
    public GameObject whatever;
    public float speed = 10.0f;

    void Update() {
        WiiUGamePad Winp = WiiUInputGamePad();

        if (Winp.GetButtonDown(WiiUGamePadButton.ButtonA)) {
            whatever.transform.Translate(speed,0,0);
        }
    }
}

I hope you won’t get confused about the the Wii U stuff, but I’ve typed it over from when I was trying to figure out the Wii U Input System (and this one is correct, by the way).

(Input.GetKeyDown(KeyCode.Z)){

make sure to have { and at the end and close it }

In JavaScript

var moveSpeed : float = 10;

function Update () 

{
if((Input.GetKey("z"))
 {
 transform.Translate (moveSpeed, 0, 0);
 }
}

@ Shrimpy’s Answer is completely right: The letter buttons on your keyboard you get with quotation marks “z”. If you use other Input devices, you have to register the buttons in the Input Manager, try searching for a tutorial if you dont understand it.