Back to Cordova

2021 07 24

slack-digest/2021-07-24.md

latest1.7 KB
Original Source

Cordova Slack Digest

Sat, 24 Jul 2021 08:20:50 GMT

User count: 4566

Join the conversation at slack.cordova.io

Channel #cordova-android (1 messages)


Fri, 23 Jul 2021 14:30:46 GMT

@ucheozoemena says

Hi folks, weird problem I've encountered. I'd appreciate some input.

I want to get linebreak (\n) characters when I hit Enter in a contenteditable div. This is a fairly common question on stack overflow, and most of the solutions revolve around 2 ideas: https://stackoverflow.com/a/19038104/7987987|using white-space: pre/pre-wrap<https://stackoverflow.com/a/19038104/7987987| in CSS>, and <https://stackoverflow.com/a/20398548/7987987|overriding the >keydown<https://stackoverflow.com/a/20398548/7987987| event to insert the desired newline char instead of the >&lt;div&gt;. There are different implementations but the core ideas are roughly always those 2. My problem is that none of the variations I've found for these 2 ideas work in my app. The first idea just seems to not work, including when combined with display: inline/inline-block and no display: flex on the parent of the contenteditable div, as some answers suggest. The second idea suffers from an android limitation that keydown<https://stackoverflow.com/questions/36753548/keycode-on-android-is-always-229| events do not report the key that has been pressed>, so it seems we're unable to confirm that the user pressed the Enter key in the keydown event handler (not after the fact, but at the moment the key is pressed). So, what's a satisfactory way around this problem? I'd really appreciate any input, thanks in advance.