/* Copyright 2024 New Vector Ltd. Copyright 2022 Šimon Brandner SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only OR LicenseRef-Element-Commercial Please see LICENSE files in the repository root for full details. */ import React, { type JSX } from "react"; import { ALTERNATE_KEY_NAME, KEY_ICON } from "../../../accessibility/KeyboardShortcuts"; import { type KeyCombo } from "../../../KeyBindingsManager"; import { IS_MAC, Key } from "../../../Keyboard"; import { _t } from "../../../languageHandler"; interface IKeyboardKeyProps { name: string; last?: boolean; } export const KeyboardKey: React.FC = ({ name, last }) => { const icon = KEY_ICON[name]; const alternateName = ALTERNATE_KEY_NAME[name]; return ( {icon || (alternateName && _t(alternateName)) || name} {!last && "+"} ); }; interface IKeyboardShortcutProps { value: KeyCombo; className?: string; } export const KeyboardShortcut: React.FC = ({ value, className = "mx_KeyboardShortcut" }) => { if (!value) return null; const modifiersElement: JSX.Element[] = []; if (value.ctrlOrCmdKey) { modifiersElement.push(); } else if (value.ctrlKey) { modifiersElement.push(); } else if (value.metaKey) { modifiersElement.push(); } if (value.altKey) { modifiersElement.push(); } if (value.shiftKey) { modifiersElement.push(); } return (
{modifiersElement}
); };