Skip to Content

Triggering enter key on press on a fragment

Hi,

I want to trigger submit button on pressing enter key.

Above shown is the scenario where i want to trigger submit button on entery key press.

How do i do that?

Please suggest me ways to achieve it.

Thanks,

Saurabh Singh.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • Best Answer
    Oct 29, 2015 at 12:57 PM

    Hi Saurabh,

    Will this help?

    http://jsbin.com/winepe/edit?html,js,output

    Use this in dialog:

      afterOpen : function(){

                $(document).bind('keypress', function(e) {

        if(e.keyCode==13){

        e.preventDefault();

                alert('Enter key Pressed');

       sap.ui.getCore().byId("idClose").firePress();

        }

      });

              }

    Thanks,

    KA

    Add comment
    10|10000 characters needed characters exceeded

  • Oct 29, 2015 at 10:07 AM

    Hi,

    Try this

    $(document).bind('keypress', function(e) {
       if(e.keyCode==13){
      $('#submit').trigger('click');
       }
    });

    Add comment
    10|10000 characters needed characters exceeded

  • Oct 30, 2015 at 08:11 AM

    Thanks KA and Dennis for your inputs. Now its working.

    Add comment
    10|10000 characters needed characters exceeded