Take the 2-minute tour ×

Does the textfield send events when its edited, or scrolled by the user?

What about key presses when focus is on the textfield? do you get those?

share|improve this question
Just adding a stock QnA to answer this basic yet hard-to-put-together answer. Notice how all of the important events (change, keypress, scroll) are NOT stored in the TextEvent class. Wierd. –  Jarvis Jan 7 '11 at 16:58
add comment

1 Answer

up vote 3 down vote accepted

Textfields send many useful events:

  • When modified by the user -- Event.CHANGE
  • When text is typed into it -- TextEvent.TEXT_INPUT
  • When a link is clicked -- TextEvent.LINK
  • When scrolled by the user -- Event.SCROLL
  • When a key is pressed -- KeyboardEvent.KEY_DOWN -- (only fires while editing a textfield)

You can easily listen for keyboard events occurring when the textfield is focused.

Just add a KEY_DOWN event directly to the textfield, and then do whatever you want.

// get key presses only when the textfield is being edited
function handler(event:KeyboardEvent){

   // if the key is ENTER
   if(event.charCode == 13){

       // your code here
share|improve this answer
add comment

Your Answer


