0

This seems like something that should've been solved by now but I haven't found a solution. I want to get linebreak (\n) characters when I hit Enter in a contenteditable div loaded in a webview on Android. This is a fairly common question on stack overflow, and most of the solutions revolve around 2 ideas: using white-space: pre/pre-wrap in CSS, and overriding the keydown 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 an android webview (in a cordova 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 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 your input, thanks in advance.

Uche Ozoemena
  • 570
  • 2
  • 5
  • 14

0 Answers0