# Key Control lag problem

**URL:** <https://forum.kirupa.com/t/key-control-lag-problem/135719>\
**Category:** Uncategorized\
**Created:** [January 29, 2005, 7:14pm UTC](https://forum.kirupa.com/t/key-control-lag-problem/135719 "2005-01-29T19:14:29Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![chup](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/chup/32/925_2.png) [@chup](https://forum.kirupa.com/u/chup)\
**Post date:** [January 29, 2005, 7:14pm UTC](https://forum.kirupa.com/t/key-control-lag-problem/135719/1 "2005-01-29T19:14:29Z")

</div>

Hi all, i got this problem with this following code.  
In a way, it work prefectly, but if you try it out and test it carefully, there is a small lag sometime which u change between the arrow key. Can anyone pls highlight to me which part of this code goes wrong?

```auto

onClipEvent (enterFrame) {
	x = this._x;
	y = this._y;

	if (xvalue == "goLeft") {
		// go left value
		this._x = this._x-3;
	}
	if (xvalue == "goRight") {
		// go right value
		this._x = this._x+3;
	}
}
onClipEvent (keyDown) {

	if (Key.getCode() == 37) {
		xvalue = "goLeft";
	}
	if (Key.getCode() == 39) {
		xvalue = "goRight";
	}
}
onClipEvent (keyUp) {
	if (Key.getCode() == 37) {
		xvalue = "stop";
	}
	if (Key.getCode() == 39) {
		xvalue = "stop";
	}
}

```

The fla is avilable here:  
[http://www.dreamance.com/download/ctrlProblem.zip](http://www.dreamance.com/download/ctrlProblem.zip)

Thanks
