Shortcuts: Check for both capital and lowercase characters

This commit is contained in:
Scott Nonnenberg 2019-11-14 12:35:59 -08:00
parent d187ab11b2
commit 3c6e23cc5e
3 changed files with 84 additions and 19 deletions

View file

@ -657,7 +657,7 @@
// Show keyboard shortcuts - handled by Electron-managed keyboard shortcuts // Show keyboard shortcuts - handled by Electron-managed keyboard shortcuts
// Navigate by section // Navigate by section
if (ctrlOrCommand && !shiftKey && key === 't') { if (ctrlOrCommand && !shiftKey && (key === 't' || key === 'T')) {
const focusedElement = document.activeElement; const focusedElement = document.activeElement;
const targets = [ const targets = [
@ -853,7 +853,12 @@
// Preferences - handled by Electron-managed keyboard shortcuts // Preferences - handled by Electron-managed keyboard shortcuts
// Open the top-right menu for current conversation // Open the top-right menu for current conversation
if (conversation && ctrlOrCommand && shiftKey && key === 'i') { if (
conversation &&
ctrlOrCommand &&
shiftKey &&
(key === 'i' || key === 'I')
) {
const button = document.querySelector( const button = document.querySelector(
'.module-conversation-header__more-button' '.module-conversation-header__more-button'
); );
@ -891,7 +896,7 @@
} }
// Search // Search
if (ctrlOrCommand && !shiftKey && key === 'f') { if (ctrlOrCommand && !shiftKey && (key === 'f' || key === 'F')) {
const { startSearch } = actions.search; const { startSearch } = actions.search;
startSearch(); startSearch();
@ -901,7 +906,12 @@
} }
// Search in conversation // Search in conversation
if (conversation && ctrlOrCommand && shiftKey && key === 'f') { if (
conversation &&
ctrlOrCommand &&
shiftKey &&
(key === 'f' || key === 'F')
) {
const { searchInConversation } = actions.search; const { searchInConversation } = actions.search;
const name = conversation.isMe() const name = conversation.isMe()
? window.i18n('noteToSelf') ? window.i18n('noteToSelf')
@ -914,7 +924,12 @@
} }
// Focus composer field // Focus composer field
if (conversation && ctrlOrCommand && shiftKey && key === 't') { if (
conversation &&
ctrlOrCommand &&
shiftKey &&
(key === 't' || key === 'T')
) {
conversation.trigger('focus-composer'); conversation.trigger('focus-composer');
event.preventDefault(); event.preventDefault();
event.stopPropagation(); event.stopPropagation();
@ -922,7 +937,12 @@
} }
// Open all media // Open all media
if (conversation && ctrlOrCommand && shiftKey && key === 'm') { if (
conversation &&
ctrlOrCommand &&
shiftKey &&
(key === 'm' || key === 'M')
) {
conversation.trigger('open-all-media'); conversation.trigger('open-all-media');
event.preventDefault(); event.preventDefault();
event.stopPropagation(); event.stopPropagation();
@ -934,7 +954,12 @@
// Open sticker picker - handled by component // Open sticker picker - handled by component
// Begin recording voice note // Begin recording voice note
if (conversation && ctrlOrCommand && shiftKey && key === 'v') { if (
conversation &&
ctrlOrCommand &&
shiftKey &&
(key === 'v' || key === 'V')
) {
conversation.trigger('begin-recording'); conversation.trigger('begin-recording');
event.preventDefault(); event.preventDefault();
event.stopPropagation(); event.stopPropagation();
@ -947,7 +972,7 @@
!conversation.get('isArchived') && !conversation.get('isArchived') &&
ctrlOrCommand && ctrlOrCommand &&
shiftKey && shiftKey &&
key === 'a' (key === 'a' || key === 'A')
) { ) {
conversation.setArchived(true); conversation.setArchived(true);
conversation.trigger('unload', 'keyboard shortcut archive'); conversation.trigger('unload', 'keyboard shortcut archive');
@ -965,7 +990,7 @@
conversation.get('isArchived') && conversation.get('isArchived') &&
ctrlOrCommand && ctrlOrCommand &&
shiftKey && shiftKey &&
key === 'u' (key === 'u' || key === 'U')
) { ) {
conversation.setArchived(false); conversation.setArchived(false);
Whisper.ToastView.show( Whisper.ToastView.show(
@ -983,7 +1008,12 @@
// Scroll to top of list - handled by component // Scroll to top of list - handled by component
// Close conversation // Close conversation
if (conversation && ctrlOrCommand && shiftKey && key === 'c') { if (
conversation &&
ctrlOrCommand &&
shiftKey &&
(key === 'c' || key === 'C')
) {
conversation.trigger('unload', 'keyboard shortcut close'); conversation.trigger('unload', 'keyboard shortcut close');
event.preventDefault(); event.preventDefault();
event.stopPropagation(); event.stopPropagation();
@ -993,7 +1023,12 @@
// MESSAGES // MESSAGES
// Show message details // Show message details
if (conversation && ctrlOrCommand && !shiftKey && key === 'd') { if (
conversation &&
ctrlOrCommand &&
!shiftKey &&
(key === 'd' || key === 'D')
) {
const { selectedMessage } = state.conversations; const { selectedMessage } = state.conversations;
if (!selectedMessage) { if (!selectedMessage) {
return; return;
@ -1006,7 +1041,12 @@
} }
// Toggle reply to message // Toggle reply to message
if (conversation && ctrlOrCommand && shiftKey && key === 'r') { if (
conversation &&
ctrlOrCommand &&
shiftKey &&
(key === 'r' || key === 'R')
) {
const { selectedMessage } = state.conversations; const { selectedMessage } = state.conversations;
conversation.trigger('toggle-reply', selectedMessage); conversation.trigger('toggle-reply', selectedMessage);
@ -1016,7 +1056,12 @@
} }
// Save attachment // Save attachment
if (conversation && ctrlOrCommand && !shiftKey && key === 's') { if (
conversation &&
ctrlOrCommand &&
!shiftKey &&
(key === 's' || key === 'S')
) {
const { selectedMessage } = state.conversations; const { selectedMessage } = state.conversations;
if (selectedMessage) { if (selectedMessage) {
@ -1028,7 +1073,12 @@
} }
} }
if (conversation && ctrlOrCommand && shiftKey && key === 'd') { if (
conversation &&
ctrlOrCommand &&
shiftKey &&
(key === 'd' || key === 'D')
) {
const { selectedMessage } = state.conversations; const { selectedMessage } = state.conversations;
if (selectedMessage) { if (selectedMessage) {
@ -1049,7 +1099,12 @@
// Send in expanded composer - handled by component // Send in expanded composer - handled by component
// Attach file // Attach file
if (conversation && ctrlOrCommand && !shiftKey && key === 'u') { if (
conversation &&
ctrlOrCommand &&
!shiftKey &&
(key === 'u' || key === 'U')
) {
conversation.trigger('attach-file'); conversation.trigger('attach-file');
event.preventDefault(); event.preventDefault();
@ -1058,7 +1113,12 @@
} }
// Remove draft link preview // Remove draft link preview
if (conversation && ctrlOrCommand && !shiftKey && key === 'p') { if (
conversation &&
ctrlOrCommand &&
!shiftKey &&
(key === 'p' || key === 'P')
) {
conversation.trigger('remove-link-review'); conversation.trigger('remove-link-review');
event.preventDefault(); event.preventDefault();
@ -1067,7 +1127,12 @@
} }
// Attach file // Attach file
if (conversation && ctrlOrCommand && shiftKey && key === 'p') { if (
conversation &&
ctrlOrCommand &&
shiftKey &&
(key === 'p' || key === 'P')
) {
conversation.trigger('remove-all-draft-attachments'); conversation.trigger('remove-all-draft-attachments');
event.preventDefault(); event.preventDefault();

View file

@ -88,7 +88,7 @@ export const EmojiButton = React.memo(
const { ctrlKey, key, metaKey, shiftKey } = event; const { ctrlKey, key, metaKey, shiftKey } = event;
const ctrlOrCommand = metaKey || ctrlKey; const ctrlOrCommand = metaKey || ctrlKey;
if (ctrlOrCommand && shiftKey && key === 'e') { if (ctrlOrCommand && shiftKey && (key === 'e' || key === 'E')) {
event.stopPropagation(); event.stopPropagation();
event.preventDefault(); event.preventDefault();

View file

@ -154,7 +154,7 @@ export const StickerButton = React.memo(
const { ctrlKey, key, metaKey, shiftKey } = event; const { ctrlKey, key, metaKey, shiftKey } = event;
const ctrlOrCommand = metaKey || ctrlKey; const ctrlOrCommand = metaKey || ctrlKey;
if (ctrlOrCommand && shiftKey && key === 's') { if (ctrlOrCommand && shiftKey && (key === 's' || key === 'S')) {
event.stopPropagation(); event.stopPropagation();
event.preventDefault(); event.preventDefault();