# Movement question

**URL:** <https://forum.kirupa.com/t/movement-question/66171>\
**Category:** flash\
**Created:** [October 3, 2004, 2:57pm UTC](https://forum.kirupa.com/t/movement-question/66171 "2004-10-03T14:57:22Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![LazyBoi105](https://avatars.discourse-cdn.com/v4/letter/l/9f8e36/32.png) [@LazyBoi105](https://forum.kirupa.com/u/LazyBoi105)\
**Post date:** [October 3, 2004, 2:57pm UTC](https://forum.kirupa.com/t/movement-question/66171/1 "2004-10-03T14:57:22Z")

</div>

ok im making a pacman type game and i got the key movements down but my question is : how do i make it so that like if u press left, the character keeps moving left until it either hits a wall or the player presses a different key … and by keep going left i mean without u having to hold the left arrow key, just press it once.

---

<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:** [October 3, 2004, 4:18pm UTC](https://forum.kirupa.com/t/movement-question/66171/2 "2004-10-03T16:18:54Z")

</div>

for the movement, create two variables in the load section

var movieclip.speedx;  
var movieclip.speedy;

then on your enterFrame, put this

movieclip.\_x+=movieclip.speedx;  
movieclip.\_y+=movieclip.speedy;

and this

if (Key.isDown(Key.UP)){  
movieclip.speedy=-5;  
movieclip.speedx=0;  
}  
if (Key.isDown(Key.DOWN)){  
movieclip.speedy=5;  
movieclip.speedx=0;  
}  
if (Key.isDown(Key.RIGHT)){  
movieclip.speedx=5;  
movieclip.speedy=0;  
}  
if (Key.isDown(Key.LEFT)){  
movieclip.speedx=-5;  
movieclip.speedy=0;  
}
