【AS3代码】键盘的输入和输出
package
{
import flash.display.Sprite;
import flash.events.KeyboardEvent;
public class Main extends Sprite
{
public function Main():void
{
init();
}
private function init():void
{
stage.addEventListener(KeyboardEvent.KEY_DOWN, aaa);
}
public function aaa(e:KeyboardEvent):void
{
//e.charCode显示输入的字符编码(会区分大小写)
//forChareCode会将字符编码转义成输入的字符显示出来
trace(String.fromCharCode(e.charCode));
}
}
}
{
import flash.display.Sprite;
import flash.events.KeyboardEvent;
public class Main extends Sprite
{
public function Main():void
{
init();
}
private function init():void
{
stage.addEventListener(KeyboardEvent.KEY_DOWN, aaa);
}
public function aaa(e:KeyboardEvent):void
{
//e.charCode显示输入的字符编码(会区分大小写)
//forChareCode会将字符编码转义成输入的字符显示出来
trace(String.fromCharCode(e.charCode));
}
}
}