Getting keyboard Input

Hello,
How does one get keyboard input? If I have a script that detects when “F” is pressed it will turn the flashlight off?

Here’s my code:

`
private var on = false;

function Update(){

if(Input.GetButtonDown(“[F]”)){

if(on){
	light.intensity =0;
on = false;
}
else {
	light.intensity =2;
on = true;
	}
}

}

`

Hi,

Accdg. to http://docs.unity3d.com/Documentation/Manual/Input.html and
http://docs.unity3d.com/Documentation/ScriptReference/Input.html

Input.GetKey (“f”);

Returns true while the user holds down the “f” key. Think auto fire.

Input.GetKeyDown (“f”);

Returns true during the frame the user starts pressing down the “f” key.

Input.GetKeyUp (“f”);

Returns true during the frame the user releases the “f” key.

if you want to find a button you have already defined:

if(Input.GetButtonDown("buttonnme")){
}

if you want to find a key not defined in your input settings:

if(Input.GetKeyDown(KeyCode.key)){
}

Check the below link it will explain the basic of input from keyboard