# Converting mouse control to arrow keys

**URL:** <https://forum.kirupa.com/t/converting-mouse-control-to-arrow-keys/314234>\
**Category:** flash\
**Created:** [September 22, 2010, 1:07pm UTC](https://forum.kirupa.com/t/converting-mouse-control-to-arrow-keys/314234 "2010-09-22T13:07:40Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![kimmy\_dora](https://avatars.discourse-cdn.com/v4/letter/k/53a042/32.png) [@kimmy\_dora](https://forum.kirupa.com/u/kimmy_dora)\
**Post date:** [September 22, 2010, 1:07pm UTC](https://forum.kirupa.com/t/converting-mouse-control-to-arrow-keys/314234/1 "2010-09-22T13:07:40Z")

</div>

hi all, can somebody help me with my codes in my flash game . Because here in my game the main character is controlled through mouse and i want it to be controlled in left and right arrow keys. Here are the codes:

on the character itself:

onClipEvent (load)  
{  
Hedding = false;  
left = this.\_width / 2;  
right = \_root.end.\_x - \_root.end.\_width / 2 - this.\_width / 2 + 50;  
time = 0;  
original\_width = this.\_width;  
}  
onClipEvent (enterFrame)  
{  
if (time \<= 0)  
{  
this.\_width = original\_width;  
} // end if  
–time;  
if (Hedding == false)  
{  
x = \_root.\_xmouse;  
left = 50 + this.\_width / 2;  
right = \_root.end.\_x - \_root.end.\_width / 2 - this.\_width / 2;  
if (x \< left)  
{  
x = left;  
}  
else if (right \< x)  
{  
x = right;  
} // end else if  
this.\_x = x;  
} // end if  
if (Hedding == false)  
{  
this.gotoAndStop(“stand”);  
} // end if  
}

in another movieclip i have placed 2 keyframes containing these codes:

KEYFRAME 1:

if (\_root.\_xmouse \> \_level0.circle.\_x)  
{  
\_level0.circle.\_x = \_level0.circle.\_x + 10;  
if (\_root.sammy.Hedding == false)  
{  
\_root.sammy.gotoAndStop(“right”);  
} // end if  
}  
else  
{  
\_level0.circle.\_x = \_level0.circle.\_x - 10;  
if (\_root.sammy.Hedding == false)  
{  
\_root.sammy.gotoAndStop(“left”);  
} // end if  
} // end else if

KEYFRAME2:

if (\_root.\_xmouse \> \_level0.circle.\_x)  
{  
\_level0.circle.\_x = \_level0.circle.\_x + 10;  
}  
else  
{  
\_level0.circle.\_x = \_level0.circle.\_x - 10;  
} // end else if  
gotoAndPlay(1);

So, my question will be how can i change the code so that the control will be  
on key left and right??? plsssssss help!!!
