In case Flash no longer exists; a copy of this site is included in the Flashpoint archive's "ultimate" collection.

Dead Code Preservation :: Archived AS3 works from wonderfl.net

keyBoard_Info

package {
    import flash.display.Sprite;
    import flash.events.Event;
    import flash.events.KeyboardEvent;
    import flash.text.TextField;
    
    public class keyBoard_Info extends Sprite {
        private var txt:TextField
        
        public function keyBoard_Info () {
            txt = new TextField();
            txt.text = "Click to get focus";
            txt.x = 100
            txt.y = 100
            txt.height=1000
            txt.width=1000;

            addChild(txt);
            
            stage.addEventListener(KeyboardEvent.KEY_DOWN, KeyDown);
            stage.addEventListener(KeyboardEvent.KEY_UP, KeyUp);
            stage.addEventListener(Event.DEACTIVATE, loseFocus); //lose focus  // --> set all keys to false
            stage.addEventListener(Event.ACTIVATE, gainFocus); //gain focus  // not required
        }
        private function KeyDown(ke:KeyboardEvent):void{
            txt.text = "keyCode: "+ke.keyCode;
            txt.appendText("\n\ncharCode: "+ke.charCode);
            txt.appendText("\nLetter: "+String.fromCharCode(ke.charCode));
            txt.appendText("\n\nKeyLocation: "+ke.keyLocation);
            txt.appendText("\nLeft or Right for Ctrl Shift and Numbers");
        } 
        private function KeyUp(ke:KeyboardEvent):void{
            
        }
        private function loseFocus(e:Event):void{
            txt.text = "Click to get focus";
        }
        private function gainFocus(e:Event):void{
            txt.text = "press a key to see it's info";
        }
    }
}