Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/actionscript-3/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Actionscript 3 使用actionscript按键盘上的enter键提交表单_Actionscript 3_Textinput_Enter - Fatal编程技术网

Actionscript 3 使用actionscript按键盘上的enter键提交表单

Actionscript 3 使用actionscript按键盘上的enter键提交表单,actionscript-3,textinput,enter,Actionscript 3,Textinput,Enter,当用户在Inputfields中输入内容并按下键盘上的enter按钮时,如何捕获键盘事件以供用户登录 我想我知道代码的第一部分。。。 txt_inputOne.addEventListener(KeyboardEvent.KEY_DOWN,keyHandler) 函数keyHandler(事件:Keyboardevent):void{ if(event.keyCode==Keyboard.ENTER) 在这之后,我对该怎么做感到困惑。要按enter按钮提交表单,是否需要我给出文本输入的值? 谢谢

当用户在Inputfields中输入内容并按下键盘上的enter按钮时,如何捕获键盘事件以供用户登录

我想我知道代码的第一部分。。。 txt_inputOne.addEventListener(KeyboardEvent.KEY_DOWN,keyHandler)

函数keyHandler(事件:Keyboardevent):void{ if(event.keyCode==Keyboard.ENTER)

在这之后,我对该怎么做感到困惑。要按enter按钮提交表单,是否需要我给出文本输入的值?
谢谢

您需要将事件侦听器添加到输入字段中

  • 对于文本字段:

    textField.addEventListener(KeyboardEvent.KEY_DOWN,handler);
    function handler(event:KeyboardEvent){
       // if the key is ENTER
       if(event.charCode == 13){
       // your code here
       // use textField.text to get the value
       }
    }
    
  • 对于文本输入:

    textInput.addEventListener(ComponentEvent.ENTER, listenerMethod);
    function handler(e:ComponentEvent):void{
            // your code here
            // use textInput.text to get the value
    }