Change scale of GameObject on key action

I tried to change scale of an on-scene GameObject using the following code in Update()

	if (Input.GetKeyDown (KeyCode.DownArrow)) {
		gameObject.transform.localScale = new Vector3 (1, 0.5f, 1);
	} else {
		gameObject.transform.localScale = new Vector3 (1, 1, 1);
	}

However, the GameObject (which is a primitive cube) flickers when down arrow is pressed. I expect the cube will keep 50% height when the down arrow is being pressed.

What did I miss out this time?

GetKeyDown returns true for the single frame that the key is pressed down. Presumably you meant GetKey instead.

if (Input.GetKeyDown (KeyCode.DownArrow))
{
gameObject.transform.localScale = new Vector3 (1, 0.5f, 1);
}
if (Input.GetKeyUP (KeyCode.DownArrow))
{
gameObject.transform.localScale = new Vector3 (1, 1, 1);
}

try this @raptorkwok