Get InputManager Key Name

Hello all,
I’m trying to show in a GUI a message like “Press [Fire1 Button]” where Fire1 Button should be replaced to the name of the key assigned by the player.

The problem is: What command I have to use to get the key name.
I’m using javascript.

Is it possible? If yes, how?

Thanks in advance and sorry my bad english.

You use the function Input.GetKey(). http://docs.unity3d.com/Documentation/ScriptReference/Input.GetKey.html

It can take either the direct name for the key http://docs.unity3d.com/Documentation/ScriptReference/KeyCode.html

or the name of the axis (that way the user can change the controls later.

Here is a example using the axis method

function Update () {
        if (Input.GetKey ("up"))
            print ("up arrow key is held down");
        if (Input.GetKey ("down"))
            print ("down arrow key is held down");
    }

Note that there is also Input.GetKeyDown and Input.GetKey that work the same but fire on key down and key up.