felixbade / assistant

Web UI for ChatGPT API. No back-end, mobile-friendly, continuously user-tested
https://assistant.bloat.app
ISC License
125 stars 25 forks source link

enter key confilct with chinese typewriting #49

Closed rainssong closed 1 year ago

rainssong commented 1 year ago

keyCode == 13 will fix this

    textbox.addEventListener('keydown', (event) => {
        if (event.keyCode == 13 && !event.ctrlKey && !event.altKey && !event.shiftKey) {
            event.preventDefault()
            submitMessageForm()
            updateTextareaSize(textbox)
        }
    })
felixbade commented 1 year ago

I would like to understand this issue so I can replicate it on my computer. Is it related to pinyin?

KeyboardEvent.keyCode is deprecated, but this might be fixable with KeyboardEvent.key.

rainssong commented 1 year ago

yep, when use pinyin, the enter means confirm english character(instead chinese character)

and event.key=='Enter' works

felixbade commented 1 year ago

event.key === 'Enter' seems to fix this issue on Firefox but not on Chrome. Might need to use the deprecated keyCode after all.

felixbade commented 1 year ago

Fixed in 375b3c0 and cd48078