3 Replies Latest reply on Apr 13, 2010 5:13 PM by david.t.lanton

    Keyboard won't respond

    david.t.lanton

      Hey,

       

      I'm trying to get familiar with the whole keyboard event detection thing.

       

      Here's my sample code.

       

      <?xml version="1.0" encoding="utf-8"?>
      <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
                     xmlns:s="library://ns.adobe.com/flex/spark"
                     xmlns:mx="library://ns.adobe.com/flex/mx"
                     creationComplete="init()">
         
          <fx:Script>
              <![CDATA[
                 
                  import flash.events.KeyboardEvent;
                  import mx.controls.Alert;
                 
                  private function init():void{
                      addEventListener(KeyboardEvent.KEY_DOWN,reportKeyDown);   
                  }
                 
                  private function reportKeyDown(event:KeyboardEvent):void {
                      Alert.show("a key was pressed");
                  }
                 
              ]]>
          </fx:Script>

      </s:Application>

       

      As you can see, I'm at stage 0 of playing around with it, but it won't work. Anyone has any idea what I should be doing instead?

       

      Thanks