【AS3代码】Keyboard键盘操作!
package
{
import flash.display.Sprite;
import flash.display.Stage;
import flash.events.KeyboardEvent;
import flash.ui.Keyboard;
import flash.events.Event;
public class Main extends Sprite
{
private var flag:Boolean = new Boolean();
public function Main():void
{
stage.addEventListener(KeyboardEvent.KEY_DOWN, a);
stage.addEventListener(KeyboardEvent.KEY_UP,b);
}
private function a(evt:KeyboardEvent):void
{
trace("点击键盘的KEY数字代码: "+evt.keyCode);
}
private function b(evt:KeyboardEvent):void
{
trace("弹起键盘的KEY数字代码: "+evt.keyCode);
}
}
}
{
import flash.display.Sprite;
import flash.display.Stage;
import flash.events.KeyboardEvent;
import flash.ui.Keyboard;
import flash.events.Event;
public class Main extends Sprite
{
private var flag:Boolean = new Boolean();
public function Main():void
{
stage.addEventListener(KeyboardEvent.KEY_DOWN, a);
stage.addEventListener(KeyboardEvent.KEY_UP,b);
}
private function a(evt:KeyboardEvent):void
{
trace("点击键盘的KEY数字代码: "+evt.keyCode);
}
private function b(evt:KeyboardEvent):void
{
trace("弹起键盘的KEY数字代码: "+evt.keyCode);
}
}
}