feat: configurable send shortcut (Enter vs Ctrl+Enter)

Add toggle in chat input to switch between Enter-to-send (default)
and Ctrl+Enter-to-send modes. Preference persists in localStorage.
Keyboard shortcuts modal reflects the current setting.
This commit is contained in:
Nicolas Varrot
2026-02-14 05:54:11 +00:00
parent 9f2e8ee9fe
commit 1c564d57b5
4 changed files with 58 additions and 5 deletions

View File

@@ -0,0 +1,21 @@
import { useState, useCallback } from 'react';
const STORAGE_KEY = 'pinchchat-send-on-enter';
/** Hook to manage the send shortcut preference (Enter vs Ctrl+Enter). */
export function useSendShortcut() {
const [sendOnEnter, setSendOnEnter] = useState(() => {
const stored = localStorage.getItem(STORAGE_KEY);
return stored === null ? true : stored === 'true';
});
const toggle = useCallback(() => {
setSendOnEnter(prev => {
const next = !prev;
localStorage.setItem(STORAGE_KEY, String(next));
return next;
});
}, []);
return { sendOnEnter, toggle };
}