Prevent user to add multiple break lines in input form

Good day!

I have a text-box field, and I want to prevent or disable the user to add multiple break lines.
I just want the user to press enter once and then type, if he clicked Enter again it won’t happen.

Because I don’t want this in the output:
Line1

Line2

line3

You can handle with an event-Handler —> onKeyPress(()=>{ }=

This code belongs into the page-----onReady() code-section.

$w('#myTextfield').onKeyPress((event)=>{console.log("Key-Pressed")

         if(pressedKey==="Enter"){console.log("ENTER pressed")
         //DO SOMETHING ---> YOUR ACTIONS HERE
         }
})

I am sorry but it say pressedKey is not identified.

Sorry my fault! This is missing in the CODE.

const pressedKey =  (event.key).toString()

@russian-dima I am so sorry but this is not working.

https://russian-dima.wixsite.com/meinewebsite/key-press-display

@russian-dima Could you please tell me how to add “Action” to prevent it double Enter or multiple newlines. I get “ENTER pressed” in the log when I press Enter.

I think it could be something like: preventDefault()
but How : )

@eslamtharwah
All you need to do is,

if (pressed —> ENTER ) {do nothing}

const pressedKey =  (event.key).toString()

if (pressedKey==="Enter") {console.log("Nothing happens here. The ENTER-button is without functionality")}
else {
    // do something
}