package { import flash.display.Sprite; import flash.events.KeyboardEvent; public class animation_ch02_KeyboardEvents extends Sprite { public function animation_ch02_KeyboardEvents() { init(); } //@ init(s) private function init():void { stage.addEventListener(KeyboardEvent.KEY_DOWN, onKeyboardEvent); stage.addEventListener(KeyboardEvent.KEY_UP, onKeyboardEvent); } //@ keyboard(s) public function onKeyboardEvent(event:KeyboardEvent):void { trace(event.type); } } }