[Flex AS3] Keyboard Events

I’ve been reading through Oreilly’s Actionscript 3.0 Cookbook and they had this example in there. As far as I can tell this does not work. If I remove the stage.focus = this; and change the addEventListener to be stage.addEventListener all is well. Is this a problem with there book or a problem with as3? Even alot of the examples in the Flex 2 help don’t work regarding this functionality.


package {
    import flash.display.Sprite;
    import flash.events.KeyboardEvent;
    
    public class ExampleApplication extends Sprite {
        public function ExampleApplication(  ) {
            stage.focus = this;
            addEventListener(KeyboardEvent.KEY_DOWN, onKeyDown);
        }
        
        private function onKeyDown(event:KeyboardEvent):void {
            trace("key down: " + event.charCode);
        }
    }
}