How to loop unity?JS

I already have the following code:

#pragma strict
    var animator : Animator;
    function Start () {
    	animator = GetComponent("Animator");
    }
    function Update () {
    	if(Input.GetKey("w") == true){
    		animator.SetBool("Walk", true);
    	} else {
    		animator.SetBool("Walk", false);
    	}
    }

but I would shake when I get giving key loop without end until the key is released! help!

did you tried if (Input.GetKeyDown(“w”)) insted of getkey

If you are using an animator, you can use the speed of the object to control the state. Check this tutorial on 2D characters. You can get a lot of concepts from there.

Have you read the documentation before comming here ?? It’s the first place you should go when you have a problem instead of coming here

Input.GetKey

Returns true while the
user holds down the key identified by
name.

Input.GetKeyUp

Returns true during the frame the user releases the key identified by name.

if( Input.GetDown("w") ){
   animator.SetBool("Walk", true);
} else if( Input.GetUp("w") ) {
   animator.SetBool("Walk", false);
}