feat: replace keypress with isComposing
Ref: https://developer.mozilla.org/en-US/docs/Web/API/Element/keydown_event#keydown_events_with_ime
This commit is contained in:
parent
80726bbce9
commit
6c5e4e4bff
1 changed files with 7 additions and 5 deletions
|
@ -8,10 +8,8 @@ const sendButton = document.getElementById("sendButton");
|
||||||
const session_uuid = self.crypto.randomUUID();
|
const session_uuid = self.crypto.randomUUID();
|
||||||
|
|
||||||
sendButton.addEventListener("click", () => {
|
sendButton.addEventListener("click", () => {
|
||||||
sendMessage();
|
sendMessage();
|
||||||
}
|
});
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
promptInput.addEventListener("input", () => {
|
promptInput.addEventListener("input", () => {
|
||||||
if (promptInput.value.split("\n").length == 1) {
|
if (promptInput.value.split("\n").length == 1) {
|
||||||
|
@ -22,7 +20,7 @@ promptInput.addEventListener("input", () => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
promptInput.addEventListener("keypress", () => {
|
promptInput.addEventListener("keydown", () => {
|
||||||
handleKeyPress(event);
|
handleKeyPress(event);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -107,6 +105,10 @@ function hideTypingIndicator() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleKeyPress(event) {
|
function handleKeyPress(event) {
|
||||||
|
if (event.isComposing || event.keyCode === 229) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (event.key == "Enter" && !event.shiftKey) {
|
if (event.key == "Enter" && !event.shiftKey) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
sendMessage();
|
sendMessage();
|
||||||
|
|
Loading…
Reference in a new issue