1 Reply Latest reply on Jul 6, 2007 11:38 AM by kglad

    Keyboard Help

    Thread7
      I want to do something that should be simple. I want to run a movie clip when a certain keyboard key is pressed. I have found various code that should let me do this but it all gives me problems. both of the following methods work in a new blank project. But when I try to put them in my existing more complex project it doesn't work.
      Using keyboard listener code like this I get "The class or interface keyboard event could not be loaded"
      -------
      function capture(event:KeyboardEvent) {
      trace("You pressed the \""+String.fromCharCode(event.charCode)+"\" key.");
      };
      stage.addEventListener(KeyboardEvent.KEY_DOWN,capture);

      ---------
      If I try using the on keypress code then nothing happens. I put this in the actionscript of a button:


      on (keyPress "<Enter>") {
      trace("Enter was pressed");
      }


      Any help would be appreciated.

      Thanks.
        • 1. Re: Keyboard Help
          kglad Adobe Community Professional & MVP
          the first code snipet is for as3. if it works when you test it (presumably in an as3 test file) and fails when you test it in your more complex project, your complex project is probably an as2 project.