I have set up a chat with a rich text box, and I want it to submit when clicking enter. It must not submit when holding shift though.
Have you simply tried just putting the onKeyPress as enter only.
$w("#yourinput").onKeypress( (event) => {
if (event.key === "Enter") {
//rest of code....
This has also been asked in previous posts, best one here to view.
https://www.wix.com/corvid/forum/community-discussion/input-onkeypress-function-working-only-after-clicking-away
Also, have a look at Keyboard Events too.
KeyboardEvent - Velo API Reference - Wix.com
Hi @sailorcihan @givemeawhisky (lol sorry, duplicate account), I still need help on this. Can you help me? Thanks!
This is my code snippet:
$w("#richTextBox1").onKeyPress((event) => {
console.log("keyPress detected")
if (event.key === "Enter") {
console.log("keyPressEnter detected")
}
})
And when looking in the console, nothing shows up.
@webmasterq the code id fine (if you put it inside $w.onReady() ). So the problem is somewhere else.
@jonatandor35 My code looks like this:
$w.onReady(() => {
//Some stuff to check if the user is logged in and has permissions
setInterval(() => {
//Maybe this snippet keeps the following from running?
refresh();
}, 1000)
$w("#richTextBox1").onKeyPress((event) => {
console.log("keyPress")
if (event.key === "Enter") {
console.log("keyPress === Enter")
}
})
})
@jonatandor35 Ok so I forgot a bracket lol. It now detects keypresses, but not the Enter.
It does not see it as a KeyPress, because the whole console log doesn’t show up when I hit Enter or Backspace.
@webmasterq So I don’t know. It worked for me many times. Are you using a standard keyboard/ A normal cellphone?
I’m using a standard keyboard yes
@webmasterq I checked it and you’re right. “Enter” and “backspace” are detected in a regular user input, but not in a RichTextBox.
Maybe it’s a bug, you should let Wix team know.
Okay, too bad though