1
0
Fork 0
forked from Mirrors/gomuks

web/composer: add preference for using ctrl+enter to send

This commit is contained in:
Tulir Asokan 2024-12-15 19:41:26 +02:00
parent c038b517c6
commit 0ebfc15ad7
2 changed files with 10 additions and 1 deletions

View file

@ -141,6 +141,12 @@ export const preferences = {
allowedContexts: anyContext,
defaultValue: true,
}),
ctrl_enter_send: new Preference<boolean>({
displayName: "Use Ctrl+Enter to send",
description: "Disable sending on enter and use Ctrl+Enter for sending instead",
allowedContexts: anyContext,
defaultValue: false,
}),
custom_notification_sound: new Preference<ContentURI>({
displayName: "Custom notification sound",
description: "The mxc:// URI to a custom notification sound.",

View file

@ -274,7 +274,10 @@ const MessageComposer = () => {
const onComposerKeyDown = useEvent((evt: React.KeyboardEvent<HTMLTextAreaElement>) => {
const inp = evt.currentTarget
const fullKey = keyToString(evt)
if (fullKey === "Enter" && (
const sendKey = fullKey === "Enter" || fullKey === "Ctrl+Enter"
? (room.preferences.ctrl_enter_send ? "Ctrl+Enter" : "Enter")
: null
if (fullKey === sendKey && (
// If the autocomplete already has a selected item or has no results, send message even if it's open.
// Otherwise, don't send message on enter, select the first autocomplete entry instead.
!autocomplete