3 Replies Latest reply on Jul 6, 2009 1:40 AM by EgorKDie

    Function keys


      There are a way to capture all function keys (F1..F24) without browser intercepting?

        • 1. Re: Function keys

          try this- http://www.adobe.com/cfusion/communityengine/index.cfm?event=showdetails&productId=2&postI d=304


          <?xml version="1.0" encoding="utf-8"?>
          <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical"
                         public function registerGlobalKeyHandler() :void
                              stage.addEventListener(KeyboardEvent.KEY_DOWN, handleKeyDown);
                         public function handleKeyDown(event:KeyboardEvent) :void
                              display.text = "Key was pressed: " + event.keyCode;
               <mx:Label id="display"
                    text="Click anywhere in the application and then press some keys." />
          • 2. Re: Function keys
            *Prashant Shelke* Level 4

            on creationComplete event of your mainApp.mxml or any outer container call

            public function init():void
                    addEventListener( KeyboardEvent.KEY_DOWN, onKeyDown );
                catch(error : Error)
                    Alert.show("error : " + error.getStackTrace());

            private function onKeyDown( event:KeyboardEvent ):void
                if (event.keyCode == Keyboard.F12)// Keyboard.F1, & so on...
                    Next code ......

            • 3. Re: Function keys
              EgorKDie Level 2

              Yes, though the guys above have missed out the "without the browser intercepting" part.


              You need to capture the keypress in javascript, and stop it from propogating through to the browser, otherwise the F5 key is going to reload your page.