How in C# do you put Keyinput into variable

Without using the input manager, in C# (think snake game, where controls spawn new blocks rather than sliding a 2d/3d object around) how do I do this:

X = key pressed

and how to I declare it (if I can use the Keycode Data type?)

I have read this - Unity - Scripting API: Input But I can only find booleens regarding the keys being pressed and I assume there should be a Keycode return function somewhere in there. please help, infinite gratitude to those who can let me continue my project.

(I am assuming this is going to be 2 lines of simple code; a declaration, and a variable assigning operation) forgive me if my terminology is backwards wrong or just made up.

Patiently refreshing email,
d74g0n

d74g0n - YouTube - http://twitter.com/d74g0n - D74g0n

public bool Xpressed;
Xpressed = Input.GetKeyDown(KeyCode.X);

Is this what your asking?

Your question seems to be a bit confusing.

Well there are basically two ways:

OnGUI is actually Unity’s event handler. It is paired with the Event class. To get the KeyCode of the button pressed you have to do this:

void OnGUI()
{
    Event e = Event.current;
    if (e.type == EventType.KeyDown)
    {
        // use e.keyCode here
    }
}