Event Flex



    xmlns:s="library://ns.adobe.com/flex/spark" creationComplete="initApp();">
    
        
    

    
         
        import mx.core.FlexGlobals; 
        private function initApp():void { 
            FlexGlobals.topLevelApplication.addEventListener(KeyboardEvent.KEY_UP,keyHandler); 
            // Set the focus somewhere inside the application. 
            ta1.setFocus(); 
        } 
        //This function quits the application if the user presses Shift+Q. 
        private function keyHandler(event:KeyboardEvent):void { 
            var bShiftPressed:Boolean = event.shiftKey; 
            if (bShiftPressed) { 
                var curKeyCode:int = event.keyCode; 
                if (curKeyCode == 81) { // 81 is the keycode value for the Q key 
                    /* Quit the application by closing the browser using JavaScript. 
                    This may not work in all browsers. */ 
                    var url:URLRequest = new 
                    URLRequest("javascript:window.close()"); 
                    navigateToURL(url,"_self"); 
                } 
            } 
        }