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:
21
src/hooks/useSendShortcut.ts
Normal file
21
src/hooks/useSendShortcut.ts
Normal 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 };
|
||||
}
|
||||
Reference in New Issue
Block a user