Search code examples
javascriptformssapui5

How to submit a SAPUI5 SimpleForm using the "Enter" key?


I have a SimpleForm inside a XML view. I would like to capture the event of the user pressing the 'enter' button, when the cursor is inside any of the fields in the Simple Form so that I can submit the form (actually I will use this pressing of the 'enter' key to fire the press event of a sap.m.Button that will submit the form). I searched the documentation but could not find a solution. Any ideas?


Solution

  • You can just use the onsapenter event.

    const oInput = new sap.m.Input();
    
    oInput.onsapenter = ((oEvent) => {
    
        alert("onEnter");
    
    });