DISQUS

Abdul Qabiz's Blog - India: Keyboard shortcuts for Flex UI components

  • JabbyPanda · 3 years ago
    Thanks for sharing this simple and elegant code, works for me in my Flex 1.5 based app.
  • Ravi · 2 years ago
    Hi
    I would like the above code ("Ctrl+1") (Keyboard shortcuts for Flex UI components) to make it work on Flex2.0 too. Since Flex2.0 doesn't have mx.utils.Delegate. Is there any alternate solutions for the above code?
    Regards,
    Ravi.G
  • Maryam · 2 years ago
    I would like this code to work fine in flex 3..could somebody help me...?
    I'm trying to do smth like this but it doesn't work in IE that takes precedences..would somebody help me to resolve this problem...?
  • Guest · 1 year ago
    You can try this solution for Flex 2/3:
  • zied · 1 year ago
    Thank you Maryam for the example, here is another example that works on flex 3:

    private function init():void{


    //your init code


    this.addEventListener(KeyboardEvent.KEY_DOWN,keyHandler);


    }





    private function keyHandler(event:KeyboardEvent):void {


    var bCTRLPressed:Boolean = event.ctrlKey;


    if( bCTRLPressed){


    var curKeyCode:int = event.keyCode;


    if(curKeyCode==83){


    //CTRL + S pressed; saveCall()


    }


    if(curKeyCode==78 ){


    //CTRL + N pressed; NewEntryCall()


    }


    if(curKeyCode == 68){


    //CTRL + D pressed; DeleteEntryCall()


    }


    if(curKeyCode == 67){


    //CTRL + C pressed; CopyCall()


    }


    if(curKeyCode == 70){


    //CTRL + F pressed; SearchCall()


    }


    }


    }



  • Anders · 10 months ago
    Instead of using


    .


    .


    var bCTRLPressed:Boolean = event.ctrlKey;


    if( bCTRLPressed){


    var curKeyCode:int = event.keyCode;


    if(curKeyCode==83){


    //CTRL + S pressed; saveCall()


    }


    .


    .




    You could just use the following:




    private function keyHandler(event:KeyboardEvent):void {


    var curKeyCode:int = event.keyCode;


    if(curKeyCode==14){


    //CTRL + N pressed;


    }


    .


    .




    No need to check if CTRL is pressed, unless you really need to react on a CTRL keypress alone.





    CTRL + [x] does have its own keyCode, ex:


    CTRL + A = 1


    CTRL + B = 2


    CTRL + C = 3


    ---


    ALT + A = 197


    ALT + B = 166


    ALT + C = 199


    ---


    A = 65


    B = 66


    C = 67







    Happy coding...

  • jorge · 4 months ago
    thank for the script ;)
    I use the script of zied and work correctly