
Код:
import flash.events.KeyboardEvent;
import flash.events.FocusEvent;
import flash.ui.Keyboard;
private function initApp():void {
this.textInput.addEventListener(FocusEvent.FOCUS_IN,this.focusHandler);
this.textInput.addEventListener(FocusEvent.FOCUS_OUT,this.blurHandler);
}
private function focusHandler(event:FocusEvent):void {
this.addEventListener(KeyboardEvent.KEY_DOWN,this.keyHandler);
}
private function blurHandler(event:FocusEvent):void {
this.removeEventListener(KeyboardEvent.KEY_DOWN,this.keyHandler);
}
private function keyHandler(event:KeyboardEvent):void {
if (event.keyCode==Keyboard.ENTER) {
this.textArea.text += this.textInput.text+'\n';
this.textInput.text = '';
}
}