while(key_name){
//do something.
}

it will do as long as the key pressed.

or if you alreay have a while(1)..wait(1) loop

just add

if(key_name){
//do something
}

it will do it.

it is no diffrent than walking forward actually
it walks only when you press and hold W(or whatever your key is or how ever you programmed it)


3333333333