mirror of
https://github.com/vector-im/element-call.git
synced 2026-07-18 18:59:23 +00:00
Add keyboard shortcut disable button.
This commit is contained in:
@@ -224,6 +224,8 @@
|
|||||||
"preferences_tab": {
|
"preferences_tab": {
|
||||||
"developer_mode_label": "Developer mode",
|
"developer_mode_label": "Developer mode",
|
||||||
"developer_mode_label_description": "Enable developer mode and show developer settings tab.",
|
"developer_mode_label_description": "Enable developer mode and show developer settings tab.",
|
||||||
|
"enable_keyboard_shortcuts_description": "Use keyboard shortcuts to control Element Call.",
|
||||||
|
"enable_keyboard_shortcuts_label": "Enable keyboard shortcuts",
|
||||||
"introduction": "Here you can configure extra options for an improved experience.",
|
"introduction": "Here you can configure extra options for an improved experience.",
|
||||||
"reactions_play_sound_description": "Play a sound effect when anyone sends a reaction into a call.",
|
"reactions_play_sound_description": "Play a sound effect when anyone sends a reaction into a call.",
|
||||||
"reactions_play_sound_label": "Play reaction sounds",
|
"reactions_play_sound_label": "Play reaction sounds",
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
|
Copyright (C) 2025 Element Creations Ltd
|
||||||
Copyright 2024 New Vector Ltd.
|
Copyright 2024 New Vector Ltd.
|
||||||
|
|
||||||
SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
|
SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
|
||||||
@@ -15,6 +16,7 @@ import {
|
|||||||
showReactions as showReactionsSetting,
|
showReactions as showReactionsSetting,
|
||||||
playReactionsSound as playReactionsSoundSetting,
|
playReactionsSound as playReactionsSoundSetting,
|
||||||
developerMode as developerModeSetting,
|
developerMode as developerModeSetting,
|
||||||
|
enableKeyboardShortcuts as enableKeyboardShortcutsSetting,
|
||||||
useSetting,
|
useSetting,
|
||||||
} from "./settings";
|
} from "./settings";
|
||||||
|
|
||||||
@@ -39,6 +41,10 @@ export const PreferencesSettingsTab: FC = () => {
|
|||||||
|
|
||||||
const [developerMode, setDeveloperMode] = useSetting(developerModeSetting);
|
const [developerMode, setDeveloperMode] = useSetting(developerModeSetting);
|
||||||
|
|
||||||
|
const [enableKeyboardShortcuts, setEnableKeyboardShortcuts] = useSetting(
|
||||||
|
enableKeyboardShortcutsSetting,
|
||||||
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<Text>{t("settings.preferences_tab.introduction")}</Text>
|
<Text>{t("settings.preferences_tab.introduction")}</Text>
|
||||||
@@ -64,6 +70,18 @@ export const PreferencesSettingsTab: FC = () => {
|
|||||||
onChange={(e) => onChangeSetting(e, setShowReactions)}
|
onChange={(e) => onChangeSetting(e, setShowReactions)}
|
||||||
/>
|
/>
|
||||||
</FieldRow>
|
</FieldRow>
|
||||||
|
<FieldRow>
|
||||||
|
<InputField
|
||||||
|
id="enableKeyboardShortcuts"
|
||||||
|
label={t("settings.preferences_tab.enable_keyboard_shortcuts_label")}
|
||||||
|
description={t(
|
||||||
|
"settings.preferences_tab.enable_keyboard_shortcuts_description",
|
||||||
|
)}
|
||||||
|
type="checkbox"
|
||||||
|
checked={enableKeyboardShortcuts}
|
||||||
|
onChange={(e) => onChangeSetting(e, setEnableKeyboardShortcuts)}
|
||||||
|
/>
|
||||||
|
</FieldRow>
|
||||||
<FieldRow>
|
<FieldRow>
|
||||||
<InputField
|
<InputField
|
||||||
id="playReactionSound"
|
id="playReactionSound"
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
|
Copyright (C) 2025 Element Creations Ltd
|
||||||
Copyright 2024 New Vector Ltd.
|
Copyright 2024 New Vector Ltd.
|
||||||
|
|
||||||
SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
|
SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
|
||||||
@@ -105,6 +106,11 @@ export const showHandRaisedTimer = new Setting<boolean>(
|
|||||||
|
|
||||||
export const showReactions = new Setting<boolean>("reactions-show", true);
|
export const showReactions = new Setting<boolean>("reactions-show", true);
|
||||||
|
|
||||||
|
export const enableKeyboardShortcuts = new Setting<boolean>(
|
||||||
|
"keyboard-shortcuts",
|
||||||
|
true,
|
||||||
|
);
|
||||||
|
|
||||||
export const playReactionsSound = new Setting<boolean>(
|
export const playReactionsSound = new Setting<boolean>(
|
||||||
"reactions-play-sound",
|
"reactions-play-sound",
|
||||||
true,
|
true,
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
|
Copyright (C) 2025 Element Creations Ltd
|
||||||
Copyright 2022-2024 New Vector Ltd.
|
Copyright 2022-2024 New Vector Ltd.
|
||||||
|
|
||||||
SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
|
SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
|
||||||
@@ -13,6 +14,7 @@ import {
|
|||||||
ReactionSet,
|
ReactionSet,
|
||||||
ReactionsRowSize,
|
ReactionsRowSize,
|
||||||
} from "./reactions";
|
} from "./reactions";
|
||||||
|
import { enableKeyboardShortcuts, useSetting } from "./settings/settings";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determines whether focus is in the same part of the tree as the given
|
* Determines whether focus is in the same part of the tree as the given
|
||||||
@@ -35,6 +37,7 @@ export function useCallViewKeyboardShortcuts(
|
|||||||
sendReaction: (reaction: ReactionOption) => void,
|
sendReaction: (reaction: ReactionOption) => void,
|
||||||
toggleHandRaised: () => void,
|
toggleHandRaised: () => void,
|
||||||
): void {
|
): void {
|
||||||
|
const [shortcutsEnabled] = useSetting(enableKeyboardShortcuts);
|
||||||
const spacebarHeld = useRef(false);
|
const spacebarHeld = useRef(false);
|
||||||
|
|
||||||
// These event handlers are set on the window because we want users to be able
|
// These event handlers are set on the window because we want users to be able
|
||||||
@@ -45,6 +48,7 @@ export function useCallViewKeyboardShortcuts(
|
|||||||
"keydown",
|
"keydown",
|
||||||
useCallback(
|
useCallback(
|
||||||
(event: KeyboardEvent) => {
|
(event: KeyboardEvent) => {
|
||||||
|
if (!shortcutsEnabled) return;
|
||||||
if (focusElement.current === null) return;
|
if (focusElement.current === null) return;
|
||||||
if (!mayReceiveKeyEvents(focusElement.current)) return;
|
if (!mayReceiveKeyEvents(focusElement.current)) return;
|
||||||
if (event.altKey || event.ctrlKey || event.metaKey || event.shiftKey)
|
if (event.altKey || event.ctrlKey || event.metaKey || event.shiftKey)
|
||||||
@@ -77,6 +81,7 @@ export function useCallViewKeyboardShortcuts(
|
|||||||
setAudioEnabled,
|
setAudioEnabled,
|
||||||
sendReaction,
|
sendReaction,
|
||||||
toggleHandRaised,
|
toggleHandRaised,
|
||||||
|
shortcutsEnabled,
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
// Because this is set on the window, to prevent shortcuts from activating
|
// Because this is set on the window, to prevent shortcuts from activating
|
||||||
@@ -90,6 +95,7 @@ export function useCallViewKeyboardShortcuts(
|
|||||||
"keyup",
|
"keyup",
|
||||||
useCallback(
|
useCallback(
|
||||||
(event: KeyboardEvent) => {
|
(event: KeyboardEvent) => {
|
||||||
|
if (!shortcutsEnabled) return;
|
||||||
if (focusElement.current === null) return;
|
if (focusElement.current === null) return;
|
||||||
if (!mayReceiveKeyEvents(focusElement.current)) return;
|
if (!mayReceiveKeyEvents(focusElement.current)) return;
|
||||||
|
|
||||||
@@ -98,7 +104,7 @@ export function useCallViewKeyboardShortcuts(
|
|||||||
setAudioEnabled?.(false);
|
setAudioEnabled?.(false);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
[focusElement, setAudioEnabled],
|
[shortcutsEnabled, focusElement, setAudioEnabled],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -106,10 +112,11 @@ export function useCallViewKeyboardShortcuts(
|
|||||||
window,
|
window,
|
||||||
"blur",
|
"blur",
|
||||||
useCallback(() => {
|
useCallback(() => {
|
||||||
|
if (!shortcutsEnabled) return;
|
||||||
if (spacebarHeld.current) {
|
if (spacebarHeld.current) {
|
||||||
spacebarHeld.current = false;
|
spacebarHeld.current = false;
|
||||||
setAudioEnabled?.(true);
|
setAudioEnabled?.(true);
|
||||||
}
|
}
|
||||||
}, [setAudioEnabled, spacebarHeld]),
|
}, [setAudioEnabled, spacebarHeld, shortcutsEnabled]),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user