Enter asks, Ctrl+Enter breaks the line — in both chat modes
Almost every message here is one line, so the common action takes the bare key. Shift+Enter also breaks a line, because that is the reflex people arrive with.
This commit is contained in:
@@ -2028,7 +2028,19 @@ vv_ai_profiles_script();
|
||||
wrapEl.addEventListener('keydown', e => {
|
||||
const inp = $('input');
|
||||
|
||||
if (e.key === 'Enter' && (e.ctrlKey || e.metaKey)) { e.preventDefault(); send(); return; }
|
||||
// Enter asks; Ctrl/Cmd+Enter breaks the line. The reverse of the usual editor convention,
|
||||
// and right for this box: almost every message here is one line, so the common action
|
||||
// gets the bare key and the rare one gets the modifier. Shift+Enter also breaks a line,
|
||||
// because that is the reflex people arrive with from every other chat box.
|
||||
if (e.key === 'Enter' && (e.ctrlKey || e.metaKey)) {
|
||||
e.preventDefault();
|
||||
const t = e.target;
|
||||
const s = t.selectionStart ?? t.value.length, n = t.selectionEnd ?? s;
|
||||
t.value = t.value.slice(0, s) + '\n' + t.value.slice(n);
|
||||
t.selectionStart = t.selectionEnd = s + 1;
|
||||
return;
|
||||
}
|
||||
if (e.key === 'Enter' && !e.shiftKey) { e.preventDefault(); send(); return; }
|
||||
|
||||
// Terminal habit: an empty box and Up gets back what you just asked, to edit rather than
|
||||
// retype. Only when empty, or it would eat cursor movement in a question being written.
|
||||
@@ -2360,7 +2372,8 @@ vv_ai_profiles_script();
|
||||
// broke the tab it lives on.
|
||||
function vv_ai_chat_keys(): array {
|
||||
return [
|
||||
['keys' => ['Ctrl', 'Enter'], 'what' => 'Ask', 'id' => 'send'],
|
||||
['keys' => ['Enter'], 'what' => 'Ask', 'id' => 'send'],
|
||||
['keys' => ['Ctrl', 'Enter'], 'what' => 'New line', 'id' => 'nl'],
|
||||
['keys' => ['↑'], 'what' => 'Your last question, to edit', 'id' => 'recall'],
|
||||
['keys' => ['/'], 'what' => 'Command — /help lists them', 'id' => 'slash'],
|
||||
['keys' => ['Esc'], 'what' => 'Close a menu, or clear the box', 'id' => 'esc'],
|
||||
|
||||
Reference in New Issue
Block a user