Merge pull request #5548 from SimonBrandner/add-search-shortcut

Add optional search shortcut
This commit is contained in:
J. Ryan Stinnett 2021-01-28 12:33:32 +00:00 committed by GitHub
commit 5431dc7331
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 26 additions and 0 deletions

View file

@ -168,6 +168,12 @@ const shortcuts: Record<Categories, IShortcut[]> = {
key: Key.U, key: Key.U,
}], }],
description: _td("Upload a file"), description: _td("Upload a file"),
}, {
keybinds: [{
modifiers: [CMD_OR_CTRL],
key: Key.F,
}],
description: _td("Search (must be enabled)"),
}, },
], ],

View file

@ -425,6 +425,14 @@ class LoggedInView extends React.Component<IProps, IState> {
handled = true; handled = true;
} }
break; break;
case Key.F:
if (ctrlCmdOnly && SettingsStore.getValue("ctrlFForSearch")) {
dis.dispatch({
action: 'focus_search',
});
handled = true;
}
break;
case Key.BACKTICK: case Key.BACKTICK:
// Ideally this would be CTRL+P for "Profile", but that's // Ideally this would be CTRL+P for "Profile", but that's
// taken by the print dialog. CTRL+I for "Information" // taken by the print dialog. CTRL+I for "Information"

View file

@ -766,6 +766,9 @@ export default class RoomView extends React.Component<IProps, IState> {
}); });
} }
break; break;
case 'focus_search':
this.onSearchClick();
break;
} }
}; };

View file

@ -52,6 +52,7 @@ export default class PreferencesUserSettingsTab extends React.Component {
'showImages', 'showImages',
'showChatEffects', 'showChatEffects',
'Pill.shouldShowPillAvatar', 'Pill.shouldShowPillAvatar',
'ctrlFForSearch',
]; ];
static GENERAL_SETTINGS = [ static GENERAL_SETTINGS = [

View file

@ -799,6 +799,8 @@
"Enable big emoji in chat": "Enable big emoji in chat", "Enable big emoji in chat": "Enable big emoji in chat",
"Send typing notifications": "Send typing notifications", "Send typing notifications": "Send typing notifications",
"Show typing notifications": "Show typing notifications", "Show typing notifications": "Show typing notifications",
"Use Command + F to search": "Use Command + F to search",
"Use Ctrl + F to search": "Use Ctrl + F to search",
"Use Command + Enter to send a message": "Use Command + Enter to send a message", "Use Command + Enter to send a message": "Use Command + Enter to send a message",
"Use Ctrl + Enter to send a message": "Use Ctrl + Enter to send a message", "Use Ctrl + Enter to send a message": "Use Ctrl + Enter to send a message",
"Automatically replace plain text Emoji": "Automatically replace plain text Emoji", "Automatically replace plain text Emoji": "Automatically replace plain text Emoji",
@ -2708,6 +2710,7 @@
"Dismiss read marker and jump to bottom": "Dismiss read marker and jump to bottom", "Dismiss read marker and jump to bottom": "Dismiss read marker and jump to bottom",
"Jump to oldest unread message": "Jump to oldest unread message", "Jump to oldest unread message": "Jump to oldest unread message",
"Upload a file": "Upload a file", "Upload a file": "Upload a file",
"Search (must be enabled)": "Search (must be enabled)",
"Jump to room search": "Jump to room search", "Jump to room search": "Jump to room search",
"Navigate up/down in the room list": "Navigate up/down in the room list", "Navigate up/down in the room list": "Navigate up/down in the room list",
"Select room from the room list": "Select room from the room list", "Select room from the room list": "Select room from the room list",

View file

@ -331,6 +331,11 @@ export const SETTINGS: {[setting: string]: ISetting} = {
displayName: _td("Show typing notifications"), displayName: _td("Show typing notifications"),
default: true, default: true,
}, },
"ctrlFForSearch": {
supportedLevels: LEVELS_ACCOUNT_SETTINGS,
displayName: isMac ? _td("Use Command + F to search") : _td("Use Ctrl + F to search"),
default: false,
},
"MessageComposerInput.ctrlEnterToSend": { "MessageComposerInput.ctrlEnterToSend": {
supportedLevels: LEVELS_ACCOUNT_SETTINGS, supportedLevels: LEVELS_ACCOUNT_SETTINGS,
displayName: isMac ? _td("Use Command + Enter to send a message") : _td("Use Ctrl + Enter to send a message"), displayName: isMac ? _td("Use Command + Enter to send a message") : _td("Use Ctrl + Enter to send a message"),