Material change on key down

Hello everyone. I’m new to unity scripting and I’m trying to make a script which changes the game objects material on a key down and change back when you hit the key again. Now I was able to get the script to work correctly but I want it to fade from one texture to the other and that is where im having the problem.
This is the code that works on key down.

var startMaterial : Material;
var change2Material : Material;

function Update() {
if (Input.GetKey("m"))
	{
		if( renderer.sharedMaterial == startMaterial )
		renderer.sharedMaterial = change2Material;
	
		else
	
		renderer.sharedMaterial = startMaterial;
	}
	}

This is the code I’m trying to make the materials fade between each other and I’m not sure what im doing wrong.

var startMaterial : Material;
var change2Material : Material;
var duration = 3.0;

function Update() {
	if (Input.GetKey("m"))
		{
		renderer.sharedMaterial = change2Material;
		}
			else 
				{
				FadeOut ();
				}
}

function FadeOut ()
{
  for (t = 0.0; t < duration; t += Time.deltaTime) {
renderer.sharedMaterial = Material.Lerp (startMaterial, change2Material, t/duration);
    yield;
  }
}

I really would appreciate it if anyone could help me. I’m a artist not a programmer so forgive me if something in the script doesn’t look correct. I put this script together from a bunch of other scripts I seen on the forums.

Input.GetKeyDown() only returns true in the exact frame that the user presses the key. If you want it to transition while you hold the key, you probably want Input.GetKey()