package {
import flash.display.*;
import flash.events.*;
import flash.ui.*;
public class Main extends Sprite {
private var upPressed:Boolean;
private var leftPressed:Boolean;
public function Main ( ) {
stage.addEventListener(KeyboardEvent.KEY_DOWN, keyDownListener);
stage.addEventListener(KeyboardEvent.KEY_UP, keyUpListener);
}
private function keyDownListener (e:KeyboardEvent):void {
if (e.keyCode == Keyboard.UP) {
upPressed = true;
} else if (e.keyCode == Keyboard.LEFT) {
leftPressed = true;
}
if (upPressed && leftPressed) {
trace("Up Arrow key and Left Arrow key are both pressed");
}
}
private function keyUpListener (e:KeyboardEvent):void {
if (e.keyCode == Keyboard.UP) {
upPressed = false;
} else if (e.keyCode == Keyboard.LEFT) {
leftPressed = false;
}
}
}
}