1 Reply Latest reply on Mar 28, 2011 10:50 AM by Flex harUI

    KeyDown event fullscreen problem

    AhmedCogenli

      I have an application, it runs full screen, I want app closed when "0" key pressed. It works very well when the app is not FS. It works in FS when I press ALT key, then it captures the keyboard events. What should be the reason?

       

      Here is the code;

       

      <?xml version="1.0" encoding="utf-8"?>
      <s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009"
                             xmlns:s="library://ns.adobe.com/flex/spark"
                             xmlns:mx="library://ns.adobe.com/flex/mx" creationComplete="windowedapplication1_creationCompleteHandler(event)">

       

          <fx:Script>
              <![CDATA[
                  import flash.events.KeyboardEvent;
                 
                  import mx.events.FlexEvent;

       


                  protected function windowedapplication1_creationCompleteHandler(event:FlexEvent):void
                  {
                     
                      systemManager.stage.displayState=flash.display.StageDisplayState.FULL_SCREEN;
                      showRedrawRegions(false);
                      showStatusBar = false;
                     
                      this.setFocus();
                      this.addEventListener(KeyboardEvent.KEY_DOWN, windowedapplication1_keyDownHandler,false, 0, true );

       

                  }
                 
                  protected function windowedapplication1_keyDownHandler(event:KeyboardEvent):void
                  {

                      if (event.keyCode == 96) {
                          this.close();
                      }

                     l1.text = event.keyCode.toString();
                  }

       


              ]]>
          </fx:Script>

       

          <fx:Declarations>
              <!-- Place non-visual elements (e.g., services, value objects) here -->
          </fx:Declarations>
          <s:Label id="l1" x="278" y="145" text="Label" width="146" height="45"/>
      </s:WindowedApplication>