3 Replies Latest reply on Nov 2, 2010 7:13 AM by BhaskerChari

    keyboard

    bindu84

      i just want to check capslock is on or off on creationComplete , It always give false either caps on or off

       

      <?xml version="1.0" encoding="utf-8"?>

      <mx:Application

       

       

      xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="init()" >

      <mx:Script>

      <![CDATA[

      im

       

       

      import mx.controls.Alert;

       

       

       

      private function init():void{

       

       

      trace("flash.ui.Keyboard.capsLock.",flash.ui.Keyboard.capsLock);

      }

       

       

       

       

      ]]>

      </mx:Script>

       

      </mx:Application>

        • 1. Re: keyboard
          BhaskerChari Level 4

          Hi Bindu,

           

          You can try this..

           

          Note: you need not check as soon as your application creationComplete is dispatched. Why becoz when user is not typing or entering something in the TextField unnecessary why to display an alert. Instead you can alert the user when he starts writing something in the TextField...which is the better way..and you can check  the same with the other sites as well..

           

          For this you can try the below code it works perfectly fine...

           

          <?xml version="1.0" encoding="utf-8"?>
          <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="init()">
          <mx:Script>
            <![CDATA[
             import mx.controls.Alert;


                   private function init():void{
                       //Called from app's creation complete event.
                       //Listener to handle any keyboard KEY_DOWN event:
                       this.addEventListener(KeyboardEvent.KEY_DOWN,handleKeyDown);
                   }
                  
                   private function handleKeyDown(event:KeyboardEvent):void
                   { 
                       if (Keyboard.capsLock){
                         Alert.show("Caps Lock Is On");
                       }
                       else
                       {
                        Alert.show("Caps Lock Is Off");
                       }
                      
                   }

            ]]>
          </mx:Script>

          <mx:TextInput width="200" height="25" />
          </mx:Application>

           

           

          Thanks,

          Bhasker

          • 2. Re: keyboard
            bindu84 Level 1

            No i need to show message on application load. Is there any way to get capslock is on or off at appliaction load.

            • 3. Re: keyboard
              BhaskerChari Level 4

              @bindu84,

               

              I don't think you can directly have a check for this..with out any user interaction like when a user presses a key.

               

              But I don't understand why do u require on creationComplete()..

               

               

              Thanks,

              Bhasker