# TextField dispatchEvent Question

**URL:** <https://forum.kirupa.com/t/textfield-dispatchevent-question/254058>\
**Category:** flash\
**Created:** [March 7, 2008, 4:43pm UTC](https://forum.kirupa.com/t/textfield-dispatchevent-question/254058 "2008-03-07T16:43:19Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![jwilliam](https://avatars.discourse-cdn.com/v4/letter/j/cc9497/32.png) [@jwilliam](https://forum.kirupa.com/u/jwilliam)\
**Post date:** [March 7, 2008, 4:43pm UTC](https://forum.kirupa.com/t/textfield-dispatchevent-question/254058/1 "2008-03-07T16:43:19Z")

</div>

Is there a difference between a user clicking on a TextField and then pressing the space bar and doing something like this in actionscript:

tf.dispatchEvent(new KeyboardEvent(KeyboardEvent.KEY\_DOWN, true, false, 32, 32));

… or maybe something like this:

tf.dispatchEvent(new MouseEvent(MouseEvent.CLICK));  
tf.dispatchEvent(new KeyboardEvent(KeyboardEvent.KEY\_DOWN, true, false, 32, 32));  
tf.dispatchEvent(new KeyboardEvent(KeyboardEvent.KEY\_UP, true, false, 32, 32));

There seems to be a difference between a user physically keying in the space and trying to duplicate this behavior in code, but I’m not sure what it is. Could someone explain it to me? Also, is there a way to accurately simulate this behavior in code?
