# I'm a newb! How to move with no diagonals

**URL:** <https://forum.kirupa.com/t/im-a-newb-how-to-move-with-no-diagonals/313394>\
**Category:** Uncategorized\
**Created:** [August 28, 2010, 7:31am UTC](https://forum.kirupa.com/t/im-a-newb-how-to-move-with-no-diagonals/313394 "2010-08-28T07:31:10Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bdizzle](https://avatars.discourse-cdn.com/v4/letter/b/85f322/32.png) [@Bdizzle](https://forum.kirupa.com/u/Bdizzle)\
**Post date:** [August 28, 2010, 7:31am UTC](https://forum.kirupa.com/t/im-a-newb-how-to-move-with-no-diagonals/313394/1 "2010-08-28T07:31:10Z")

</div>

I’m using this code right now for a moving background:

onClipEvent (load) {  
movespeed = 8;  
}  
onClipEvent (enterFrame) {  
if (Key.isDown(Key.RIGHT)) {  
\_x-= movespeed;  
}  
if (Key.isDown(Key.LEFT)) {  
\_x+= movespeed;  
}  
if (Key.isDown(Key.UP)) {  
\_y+= movespeed;  
}  
if (Key.isDown(Key.DOWN)) {  
\_y-= movespeed;  
}  
}  
but the problem is that pressing combinations of arrows moves the background diagonally (up+left; down+right; etc.)

I do NOT want diagonal character movement at all! I just want up/down/left right. So how do I code this??

Also, is there a better way to write the code above to be shorter?

Thanks!! :megaman\_classic:
