Catch enter key press in input text field in AS3

Posted by Jonathan Barbero on Stack Overflow See other posts from Stack Overflow or by Jonathan Barbero
Published on 2010-02-19T15:22:47Z Indexed on 2010/05/30 7:42 UTC
Read the original article Hit count: 465

Filed under:

Hello,

I want to catch the enter key press when the user is filling an input text field in AS3. I think I have to do something like this:

    inputText.addEventListener(Event. ? , func);
    function func(e:Event):void{
       if(e. ? == "Enter"){
          doSomething();
       }
    }

But I can't find the best way to do this. By the way, the input text has a restriction:

inputText.restrict = "0-9";

Should I add the enter key to the restrictions?

inputText.restrict = "0-9\n";

Thanks in advance.

© Stack Overflow or respective owner

Related posts about actionscript-3