How to allow the player to change quality in-game?

The game im making is fast with the fantastic checked until you get to one spot in the game where it lags (13 fps) and I was able to change my quality to fastest. Is there a way that the player can choose fastest then once they get to that one scene they can click 1 to make it switch to fastest? Please help, my game is depending on this!
(if there must be scripting then please try to have it in javascript but i will accept c#)

Found out how (Javascript):

#pragma strict

var qualityLevel = QualitySettings.GetQualityLevel ();

function Update () {
	if (Input.GetKeyDown("1")) //Fastest Quality
	{
		QualitySettings.SetQualityLevel (0, true);
	}

	if (Input.GetKeyDown("2")) //Fast Quality
	{
		QualitySettings.SetQualityLevel (1, true);
	}

	if (Input.GetKeyDown("3")) //Simple Graphics
	{
	QualitySettings.SetQualityLevel (2, true);
	}

	if (Input.GetKeyDown("4")) //Good Graphics
	{
	QualitySettings.SetQualityLevel (3, true);
	}

	if (Input.GetKeyDown("5")) //Beautiful Graphics
	{
	QualitySettings.SetQualityLevel (4, true);
	}

	if (Input.GetKeyDown("6")) //Fantastic Graphics
	{
	QualitySettings.SetQualityLevel (5, true);
	}

}