Search This Blog

Tuesday, July 5, 2011

Flex ctrl+r key press; Flex ctrl+f key press; Flex ctrl+F key press

 

To intercept the above key presses you need to register an event handler (possibly in an init function or any onCreation event) like this:

stage.addEventListener(KeyboardEvent.KEY_DOWN, mainWindow_keyDownHandler);

The function looks as follows:

protected function mainWindow_keyDownHandler(event:KeyboardEvent):void
        {
            if (event.ctrlKey && event.charCode == 114)
//ctrl+r
            {

                button2_clickHandler(null); //refresh
            }
           
            if (event.ctrlKey && event.charCode == 102) { //ctrl+f
                button3_clickHandler(null); //custom filter
            }
           
            if (event.ctrlKey && event.shiftKey && event.charCode == 70) { //ctrl+F
                button1_clickHandler(null); //full screen
            }
        }

1 comment:

  1. This method doesn't work (for example on my IE 9.0.8112).
    When I add keyboard listener on addedToStage event, then press ctrl+r -> my flex app reloads...

    PS: on creationComplete event, stage object doesn't created (stage == null)

    PPS: sorry for my english - i'm learning it at this time :)

    ReplyDelete

If you like this post, please leave a comment :)