title: Flash: KeyboardEvent keycodes work in Flash Player, but not the browser
body: <p>I'm using ActionScript to listen for key presses and route to a method to handle them. It works fine in Flash Player Debugger 10.1, but does not work with the SWF in a browser. </p>
  
  <p>I've tried it with all sorts of keys: letters, numbers, etc. But I can't get it to work at all in the browser. I'm using Safari 5.1 and Firefox 3.6.8 on the Mac.</p>
  
  <p>Here's my relevant code:</p>
  
  <pre><code>import flash.events.KeyboardEvent;
  
  stage.addEventListener(KeyboardEvent.KEY_DOWN,keyPressed);
  
  public function keyPressed(k:KeyboardEvent):void
      {
          switch(k.keyCode)
          {
              case(32):
                  // spacebar
                  demoTimeline.pause();
                  break;
              case(leftArrow):
                  // left arrow - 188
                  demoTimeline.reverse();
                  break;
              case(rightArrow):
                  // right arrow - 190
                  demoTimeline.play();
                  break;
              case(191):
                  // question mark - 191
                  demoTimeline.restart();
                  break;
          }
      }
  </code></pre>