2 Replies Latest reply on Jul 31, 2010 9:23 AM by thebuntha

    Problem regarding KeyBoardEvent

    thebuntha

      I was trying a keyboard event example and could not understand a logic . The code was -

       

       

      <?xml version="1.0" encoding="utf-8"?>
      <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
          xmlns:s="library://ns.adobe.com/flex/spark" 
          xmlns:mx="library://ns.adobe.com/flex/mx" 
          minWidth="955" minHeight="600"
          creationComplete="initApp()">
       
       <!-- Place non-visual elements (e.g., services, value objects) here -->
       <s:layout>
       <s:VerticalLayout/>
       </s:layout>
       <fx:Declarations>
       </fx:Declarations>
       <fx:Script>
       <![CDATA[
       import mx.core.FlexGlobals;
       internal function initApp():void{
       FlexGlobals.topLevelApplication.addEventListener(KeyboardEvent.KEY_UP,keyUp);
       }
       
       internal function keyUp(event:KeyboardEvent):void{
       label.text = event.keyCode+"/"+event.charCode;
       }
       
       ]]>
       </fx:Script>
       <s:TextInput id="input" focusEnabled="true"/>
       <s:Label id="label"/>
      

      </s:Application>

       

      In the above example , in the listener we are appending KEY_UP but in the keyboard if we try any key like any character key , it sets the value of label.

      So how does it happening. If the listener is being set for only Key_UP stroke , why the label is changing for clicking any key on the keyboard.