Skip to content

Commit

Permalink
fix: tray uses the Enter key to send a message (lencx#533)
Browse files Browse the repository at this point in the history
  • Loading branch information
lencx authored and Somsak Meesangpetch committed Jul 24, 2023
1 parent 85d2bb9 commit bbe1478
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src-tauri/src/scripts/cmd.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,12 @@ async function cmdTip() {
// Enter a command starting with `/` and press a space to automatically fill `chatgpt prompt`.
// If more than one command appears in the search results, the first one will be used by default.
function cmdKeydown(event) {

if (!window.__CHAT_MODEL_CMD_PROMPT__) {
if (!event.shiftKey && event.keyCode === 13 && __TAURI_METADATA__.__currentWindow.label === 'tray') {
const btn = document.querySelector('form button');
if (btn) btn.click();
event.preventDefault();
}
return;
}

Expand Down Expand Up @@ -249,11 +253,6 @@ async function cmdTip() {

event.preventDefault();
}

if (event.keyCode === 13 && __TAURI_METADATA__.__currentWindow.label === 'tray') {
const btn = document.querySelector('form button');
if (btn) btn.click();
}
}
searchInput.removeEventListener('keydown', cmdKeydown, { capture: true });
searchInput.addEventListener('keydown', cmdKeydown, { capture: true });
Expand Down

0 comments on commit bbe1478

Please sign in to comment.