2 Replies Latest reply on Aug 2, 2010 7:55 AM by NickDF__

    Caps Lock Event Listener

    NickDF__ Level 1

      Hello to all,


      I was spending some time with event listeners today and I thought of listening for the status of the caps lock.


      Didnt find a way to check it so maybe the listener is the best way to do it.


      Any thoughts on how this can be achieved? It would be very helpfull for login purposes to see if the user is typing with caps lock on.

        • 1. Re: Caps Lock Event Listener
          rtalton Level 4

          For a key Up/DOWN event, the CapsLock KeyCode is 20. But you should use the Keyboard.CAPS_LOCK constant instead.

          In a Keyboard event handler:

                       if (event.keyCode == Keyboard.CAPS_LOCK){

                           // true if capslock was pressed



          To check if the key is toggled on or off, do this:

                       if (Keyboard.capsLock){
                        //true if caps lock is on; false if not.


          Add a listener like this:

                  public function addHandler():void{
                      //Called from app's creation complete event.
                      //Listener to handle any keyboard KEY_DOWN event:

          • 2. Re: Caps Lock Event Listener
            NickDF__ Level 1

            exactly what I needed. thanks a lot.