# How Do You

**URL:** <https://forum.kirupa.com/t/how-do-you/24156>\
**Category:** Uncategorized\
**Created:** [June 26, 2003, 5:38pm UTC](https://forum.kirupa.com/t/how-do-you/24156 "2003-06-26T17:38:47Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![scarce](https://avatars.discourse-cdn.com/v4/letter/s/65b543/32.png) [@scarce](https://forum.kirupa.com/u/scarce)\
**Post date:** [June 26, 2003, 5:38pm UTC](https://forum.kirupa.com/t/how-do-you/24156/1 "2003-06-26T17:38:47Z")

</div>

move a movie clip with the arrow keys, but using coding in the Timeline in a frame? After this i have one more question…been trying to find this out for 2 days now ☹

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [June 26, 2003, 6:22pm UTC](https://forum.kirupa.com/t/how-do-you/24156/2 "2003-06-26T18:22:40Z")

</div>

Give your mc an instancename. In this example we’ll use ‘mover’ (without the ‘’). Now choose a method.

\<hr\>  
easy method. This will overwrite any onClipEvent(enterFrame) code that resides on the mc itself.  
\<hr\>

mover.keypressed = 0;  
mover.onKeyDown = function(){  
this.keypressed = Key.getCode();  
}  
mover.onKeyUp = function(){  
this.keypressed = 0;  
}  
mover.onEnterFrame = function(){  
//key-checking and moving goes here, something like if(this.keypressed == key.LEFT) {  
this.\_x-= 5;  
}  
}  
\<hr\>  
harder (but more versatile) method. U can use other code on the mc, without disturbing the code.  
\<hr\>  
obj\_mover={keypressed:0};  
obj.\_mover.onKeyUp = function(){  
this.keypressed = 0;  
}  
obj.\_mover.onKeyDown = function(){  
this.keypressed = Key.getCode();  
}  
ob\_mover.onEnterFrame = function(){  
//key-checking and moving goes here, something like if(this.keypressed == key.LEFT) {  
mover.\_x -= 5:  
}  
}  
Key.addListener(obj\_mover)  
// to not listen for ikoming keypresses, use Key.removeListener(obj\_mover)
