# Keyboard focus not the same as focus?

**URL:** <https://forum.kirupa.com/t/keyboard-focus-not-the-same-as-focus/284213>\
**Category:** Uncategorized\
**Created:** [March 16, 2009, 6:49pm UTC](https://forum.kirupa.com/t/keyboard-focus-not-the-same-as-focus/284213 "2009-03-16T18:49:09Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![that1guy](https://avatars.discourse-cdn.com/v4/letter/t/b9e5f3/32.png) [@that1guy](https://forum.kirupa.com/u/that1guy)\
**Post date:** [March 16, 2009, 6:49pm UTC](https://forum.kirupa.com/t/keyboard-focus-not-the-same-as-focus/284213/1 "2009-03-16T18:49:09Z")

</div>

I have a TextField called textField on the first frame of the main timeline, and this simple code.

```auto
import flash.events.KeyboardEvent;
import flash.events.FocusEvent;

textField.addEventListener(KeyboardEvent.KEY_DOWN,
   function(event:KeyboardEvent):void { trace("textField key listener"); });

textField.addEventListener(FocusEvent.FOCUS_IN,
   function(event:FocusEvent):void { trace("textField focus listener"); });

stage.addEventListener(FocusEvent.FOCUS_IN,
   function(event:FocusEvent):void { trace("stage focus: " + stage.focus); });

stage.focus = textField;

```

When I compile, “textField focus listener” traces and “stage focus: [object TextField]” traces, but nothing traces when I press keys.

If I click on the TextField, nothing traces at the time, but then if I hit keys afterward, “textField key listener” finally traces.

What the heck is going on? How do I set the TextField to receive KeyboardEvents if not with “stage.focus”? Do you get the same result if you copy and paste this code?
