2 Replies Latest reply on Jun 24, 2010 7:20 AM by Kellywww

    Using keys to activate buttons


      I have done up a flash demo which uses the computer mouse to navigate. Now instead of using mouse, I want to use keyboard (arrow up, down, left, right) to highlight buttons and then hit "enter" key to click the button.


      Can anyone help? Thank you in advance.

        • 1. Re: Using keys to activate buttons



          To use keyboard, You need to add a event listener for keyboard. Please find a sample code below:


          button_name.addEventListener(KeyboardEvent.KEY_DOWN, function_name);

          function function_name(e:KeyboardEvent) {

          if (e.keyCode == 13) {

          //code for list of actions after entering ENTER key




          For enter key, keycode is 13. For Up, down, left, right you need to add a keycode like above and the code should be placed accordingly.



          1 person found this helpful
          • 2. Re: Using keys to activate buttons
            Kellywww Level 1

            Hi selangov


            1) Am I right to say that the event listener script is a frame script?

            2) So the button script is empty?

            3) My buttons are layout vertically, so I need to use the arrow up and down to "highlight" (which is rollover) the buttons before clicking it. How do I make use of your script?


            Please advise. Appreciate so very much!