Skip to main content
Participant
April 12, 2013
Question

KeyboardEvent Enter Key

  • April 12, 2013
  • 5 replies
  • 1239 views

On stage i have a button, TextInput and a TextArea component. I want the user to add some content in the TextInput field and when Enter is clicked on the Keyboard the content will be transferred and displayed in the TextArea. How do i do this?  I know the keyCode == Keyboard.ENTER is to recognize when enter is pressed but to do this is more complicated.

Thank You

This topic has been closed for replies.

5 replies

Participating Frequently
July 30, 2019

the swf isn't animate beyond the playhead moving through 352 keyframes, each with another letter added to create a document. if not touched, it just sits dormant. there is no way to script goto(1) on enter key event?

Participating Frequently
July 30, 2019

what about linking a key to the rewind function in the flash player interface?

kglad
Community Expert
Community Expert
July 30, 2019

i know of no such thing

Participating Frequently
July 30, 2019

will that allow me to interrupt the sequence though in the middle of it and reset the scene to frame 1?

The context of this may help clarify, I have a large paragraph of text that I have broken into keyframes (1letter/space per keyframe)

as the actor taps the keys and the playhead moves forward "typing out my paragraph", I would like to assign a key for the props person that will allow them to stop the scene if there is mistake and quickly start anew without having to keypress 352 times to get to the end of the paragraph.

kglad
Community Expert
Community Expert
July 30, 2019

it won’t stop code that’s executing but it will move the playhead to frame 1.  it won’t reset anything

Ned Murphy
Legend
April 12, 2013

Assign a listener for a KeyboardEvent and if the event indicates the Enter key was used, write the text to the textarea.

stage.addEventListener(KeyboardEvent.KEY_UP, writeText);

function writeText(event:KeyboardEvent):void {
    if(event.keyCode == Keyboard.ENTER){
         //  write the text to the textarea   

    }
}

rickyhaydAuthor
Participant
April 12, 2013

Appreciate your help guys. Tested the code and worked nicely.

Ned Murphy
Legend
April 12, 2013

You're welcome

kglad
Community Expert
Community Expert
April 12, 2013

stage.addEventListener(KeyboardEvent.KEY_DOWN,keydownF);

function keydownF(e:KeyboardEvent):void{

if(e.keyCode==Keyboard.ENTER){

yourtextarea.text=yourtextinput.text;

}

}