Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New line on enter #220

Open
unmellow opened this issue Jul 20, 2023 · 2 comments
Open

New line on enter #220

unmellow opened this issue Jul 20, 2023 · 2 comments

Comments

@unmellow
Copy link

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.

@LennartCode
Copy link

+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! :)

@krunal-jethva-tark
Copy link

krunal-jethva-tark commented Oct 3, 2024

📝 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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants