macOS shortcuts: Only listen for command key, not control key

This commit is contained in:
Scott Nonnenberg 2019-12-17 10:52:36 -08:00 committed by Ken Powers
parent d86e8ef7ec
commit 2c7baad68d
10 changed files with 59 additions and 39 deletions

View file

@ -704,7 +704,9 @@
const { altKey, ctrlKey, key, metaKey, shiftKey } = event;
const optionOrAlt = altKey;
const ctrlOrCommand = metaKey || ctrlKey;
const commandKey = window.platform === 'darwin' && metaKey;
const controlKey = window.platform !== 'darwin' && ctrlKey;
const commandOrCtrl = commandKey || controlKey;
const state = store.getState();
const selectedId = state.conversations.selectedConversation;
@ -715,7 +717,7 @@
// Show keyboard shortcuts - handled by Electron-managed keyboard shortcuts
// However, on linux Ctrl+/ selects all text, so we prevent that
if (ctrlOrCommand && key === '/') {
if (commandOrCtrl && key === '/') {
window.showKeyboardShortcuts();
event.stopPropagation();
@ -725,7 +727,7 @@
}
// Navigate by section
if (ctrlOrCommand && !shiftKey && (key === 't' || key === 'T')) {
if (commandOrCtrl && !shiftKey && (key === 't' || key === 'T')) {
window.enterKeyboardMode();
const focusedElement = document.activeElement;
@ -924,7 +926,7 @@
// Open the top-right menu for current conversation
if (
conversation &&
ctrlOrCommand &&
commandOrCtrl &&
shiftKey &&
(key === 'l' || key === 'L')
) {
@ -965,7 +967,7 @@
}
// Search
if (ctrlOrCommand && !shiftKey && (key === 'f' || key === 'F')) {
if (commandOrCtrl && !shiftKey && (key === 'f' || key === 'F')) {
const { startSearch } = actions.search;
startSearch();
@ -977,7 +979,7 @@
// Search in conversation
if (
conversation &&
ctrlOrCommand &&
commandOrCtrl &&
shiftKey &&
(key === 'f' || key === 'F')
) {
@ -995,7 +997,7 @@
// Focus composer field
if (
conversation &&
ctrlOrCommand &&
commandOrCtrl &&
shiftKey &&
(key === 't' || key === 'T')
) {
@ -1008,7 +1010,7 @@
// Open all media
if (
conversation &&
ctrlOrCommand &&
commandOrCtrl &&
shiftKey &&
(key === 'm' || key === 'M')
) {
@ -1025,7 +1027,7 @@
// Begin recording voice note
if (
conversation &&
ctrlOrCommand &&
commandOrCtrl &&
shiftKey &&
(key === 'v' || key === 'V')
) {
@ -1039,7 +1041,7 @@
if (
conversation &&
!conversation.get('isArchived') &&
ctrlOrCommand &&
commandOrCtrl &&
shiftKey &&
(key === 'a' || key === 'A')
) {
@ -1074,7 +1076,7 @@
if (
conversation &&
conversation.get('isArchived') &&
ctrlOrCommand &&
commandOrCtrl &&
shiftKey &&
(key === 'u' || key === 'U')
) {
@ -1096,7 +1098,7 @@
// Close conversation
if (
conversation &&
ctrlOrCommand &&
commandOrCtrl &&
shiftKey &&
(key === 'c' || key === 'C')
) {
@ -1111,7 +1113,7 @@
// Show message details
if (
conversation &&
ctrlOrCommand &&
commandOrCtrl &&
!shiftKey &&
(key === 'd' || key === 'D')
) {
@ -1129,7 +1131,7 @@
// Toggle reply to message
if (
conversation &&
ctrlOrCommand &&
commandOrCtrl &&
shiftKey &&
(key === 'r' || key === 'R')
) {
@ -1144,7 +1146,7 @@
// Save attachment
if (
conversation &&
ctrlOrCommand &&
commandOrCtrl &&
!shiftKey &&
(key === 's' || key === 'S')
) {
@ -1161,7 +1163,7 @@
if (
conversation &&
ctrlOrCommand &&
commandOrCtrl &&
shiftKey &&
(key === 'd' || key === 'D')
) {
@ -1187,7 +1189,7 @@
// Attach file
if (
conversation &&
ctrlOrCommand &&
commandOrCtrl &&
!shiftKey &&
(key === 'u' || key === 'U')
) {
@ -1201,7 +1203,7 @@
// Remove draft link preview
if (
conversation &&
ctrlOrCommand &&
commandOrCtrl &&
!shiftKey &&
(key === 'p' || key === 'P')
) {
@ -1215,7 +1217,7 @@
// Attach file
if (
conversation &&
ctrlOrCommand &&
commandOrCtrl &&
shiftKey &&
(key === 'p' || key === 'P')
) {