Matrix
Matrix

Reputation: 9

AS3 Event listener for typing in textfield

When I type in the textfield I want an event listener to start. But I only want it so when you start typing, not when you click on it. Im not too sure how to go about this. What do I do?

Upvotes: 0

Views: 446

Answers (2)

Josh
Josh

Reputation: 8159

Use KeyboardEvent.Key_UP

var tf:TextField = new TextField();
tf.addEventListener(KeyboardEvent.KEY_UP, keyUpHandler);

function keyUpHandler(e:KeyboardEvent):void {
    // do something
}

If you need to know what character was typed, look at KeyboardEvent.keyCode

Upvotes: 0

Marty
Marty

Reputation: 39466

TextFields dispatch two events which would be helpful for achieving that:

Event.CHANGE KeyboardEvent.KEY_UP

Upvotes: 3

Related Questions