Open unmellow opened 1 year ago
+1 This is also the case for Slack. Maybe this is a CR/LF thing? On other apps, enter is interpreted correctly as a new line instead of a post. Signal and WhatsApp get it correctly. Interestingly it works as intended on Gboard.
Hope this helps! :)
📝 Note to developers:
If you're coming here to find a solution for the simple-keyboard
JavaScript library, this is not the one you're looking for 😅.
For some reason, both Google and Bing searches led me to this issue repeatedly over the last two days, and I initially thought Enter key functionality was not supported in the simple-keyboard
library.
However, after a deep inspection of the simple-keyboard
library's code, I discovered that there is a built-in option you can use:
options.newLineOnEnter
:
You can set this option based on your requirements to handle the Enter key functionality directly within the library.
Example:
const keyboard = new Keyboard({
newLineOnEnter: true, // This enables adding a newline when the "Enter" key is pressed
});
This will automatically handle the "Enter" key and insert a new line (\n
) at the current cursor position without the need for manual handling.
🎯 Key takeaway:
If you're trying to add a newline on the Enter key press in simple-keyboard
, just set the newLineOnEnter
option to true
. It works out of the box!
Certain apps like discord have a separate submit button, and expect the enter key to be used to enter a new line.
It would be nice to have simple keyboard match this functionality.