title: Clicking button using keyboard in AS3
body: <p>I am trying to do this by clicking on button using 'A' key in keyboard. I created two frames for this button but the code doesn't work, although there is no error.</p>
  
  <p>Do I need to put anything in my main class? Can anyone help to fix this?</p>
  
  <pre><code>package  {
  
      import flash.display.MovieClip;
      import flash.events.MouseEvent;
      import flash.display.Sprite;
      import flash.display.Stage;
      import flash.events.Event;
      import flash.events.KeyboardEvent;
      import flash.ui.Keyboard;
  
      public class controlButton extends MovieClip {      
  
          public function controlButton() {
              // constructor code
              this.addEventListener(KeyboardEvent.KEY_DOWN,clickDown);
              this.addEventListener(KeyboardEvent.KEY_UP,clickUp);
          }
  
          public function clickDown(event:KeyboardEvent):void{
  
           // if the key is A
              if(event.charCode == 65){
                  this.gotoAndStop(2);
              }
          }
  
          public function clickUp(event:KeyboardEvent):void{
  
           // if the key is A
              if(event.charCode == 65){
                  this.gotoAndStop(1);
              }
          }
  
          public function changelabel(newLabel:String):void{
  
              this.label.text = newLabel;
          }
      }
  }
  </code></pre>