Allowing Enter Key in Input

Hi Outsystems,


I have this regex in extended properties:

onkeyup: 

"this.value=this.value.replace(/[^a-zA-Z0-9 /-?:().,'+]/g,'')"

and I want to allow the Enter key as well.

Any idea how can I accomplish this?


Regards,


Pedro Santos

Hello Pedro, you can use the event on keyPressed like this. You can add an event listener waiting for the.

Or add to the events of your widget the onkeypress.

The event key code for entering is 13.

onkeypress
   function enterKeyPressed(event) {
      if (event.keyCode == 13) {
         console.log("Enter key is pressed");
         return true;
      } else {
         return false;
      }
   }

Look at this example

https://www.tutorialspoint.com/enter-key-press-event-in-javascript

Kind regards,

Márcio

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.