slack-digest/2021-07-24.md
Sat, 24 Jul 2021 08:20:50 GMT
Join the conversation at slack.cordova.io
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
Enterin 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|usingwhite-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 ><div>. 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 withdisplay: inline/inline-blockand nodisplay: flexon the parent of the contenteditable div, as some answers suggest. The second idea suffers from an android limitation thatkeydown<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 thekeydownevent 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.