# Wasd not working

**URL:** <https://forum.kirupa.com/t/wasd-not-working/319289>\
**Category:** flash\
**Created:** [February 15, 2011, 3:22pm UTC](https://forum.kirupa.com/t/wasd-not-working/319289 "2011-02-15T15:22:28Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![NuclearTeddies](https://avatars.discourse-cdn.com/v4/letter/n/839c29/32.png) [@NuclearTeddies](https://forum.kirupa.com/u/NuclearTeddies)\
**Post date:** [February 15, 2011, 3:22pm UTC](https://forum.kirupa.com/t/wasd-not-working/319289/1 "2011-02-15T15:22:28Z")

</div>

Hello guys,

I have a very strange problem and i can’t get it fixed. I’m trying to let my ship move with WASD. I’ve got it to work with the arrow keys, no problem.  
It seems to be the problem that my event isn’t triggered when i press W, A, S or D. Because, when i place a trace(event.keyCode), it doesn’t trace anything.  
I’m using this within a class.  
Here’s my (part of the) code:

```auto
public function ship() {
			stage.addEventListener(KeyboardEvent.KEY_DOWN, keysDown);
			stage.addEventListener(KeyboardEvent.KEY_UP, keysUp);
			addEventListener(Event.ENTER_FRAME, onEnter);

		}

```

and:

```auto
		private function keysDown(event:KeyboardEvent):void {
			switch (event.keyCode) {
				case 87 :
					upPressed=true;
					break;
				case Keyboard.DOWN :
					downPressed=true;
					break;
				case Keyboard.LEFT :
					leftPressed=true;
					break;
				case Keyboard.RIGHT :
					rightPressed=true;
					break;
				case Keyboard.SPACE :
					spacePressed=true;
					break;
			}
		}
		private function keysUp(event:KeyboardEvent):void {
			switch (event.keyCode) {
				case 87 :
					upPressed=false;
					break;
				case Keyboard.DOWN :
					downPressed=false;
					break;
				case Keyboard.LEFT :
					leftPressed=false;
					break;
				case Keyboard.RIGHT :
					rightPressed=false;
					break;
				case Keyboard.SPACE :
					spacePressed=false;
					break;
			}
		}

```

In the code above, the W key doesn’t work. But the left, right and down arrow keys work fine. If i change those to the corresponding key values of a, s and d.  
It doesn’t work anymore.

Please help me,

Please note: I’m new to as3. I’ve been programming with as2 for 2 years. Now i’m migrating to as3.
