From a008f5010ab93cb6016efc0b6be24c776bfedb11 Mon Sep 17 00:00:00 2001 From: David Baker Date: Tue, 8 Nov 2016 18:04:22 +0000 Subject: [PATCH] Fix the ctrl+e mute camera shortcut * Fixes the altgr+e shortcut on Windows (Fixes https://github.com/vector-im/vector-web/issues/2561) * Fixes the shortcuts to be cmd+e on mac rather than ctrl+e which is more normal and doesn't clobber ctrl+e which old school unix types use for go-to-end-of-line. --- src/components/structures/RoomView.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/components/structures/RoomView.js b/src/components/structures/RoomView.js index 4e578d8d289..2d71943bced 100644 --- a/src/components/structures/RoomView.js +++ b/src/components/structures/RoomView.js @@ -358,18 +358,25 @@ module.exports = React.createClass({ }, onKeyDown: function(ev) { - var handled = false; + let handled = false; + const isMac = navigator.platform.toUpperCase().indexOf('MAC') >= 0; + let ctrlCmdOnly; + if (isMac) { + ctrlCmdOnly = ev.metaKey && !ev.altKey && !ev.ctrlKey && !ev.shiftKey; + } else { + ctrlCmdOnly = ev.ctrlKey && !ev.altKey && !ev.metaKey && !ev.shiftKey; + } switch (ev.keyCode) { case KeyCode.KEY_D: - if (ev.ctrlKey) { + if (ctrlCmdOnly) { this.onMuteAudioClick(); handled = true; } break; case KeyCode.KEY_E: - if (ev.ctrlKey) { + if (ctrlCmdOnly) { this.onMuteVideoClick(); handled = true; }