From 0dbd1d988ec2509af09c51f58a88287064d68cea Mon Sep 17 00:00:00 2001 From: Luke Barnard Date: Wed, 12 Jul 2017 13:51:55 +0100 Subject: [PATCH 1/2] Enable ctrl+k room filter focus By using the `focus_room_filter` dispatch --- src/components/structures/LoggedInView.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/components/structures/LoggedInView.js b/src/components/structures/LoggedInView.js index f1053618dc..9750a2c99b 100644 --- a/src/components/structures/LoggedInView.js +++ b/src/components/structures/LoggedInView.js @@ -184,6 +184,13 @@ export default React.createClass({ handled = true; } break; + case KeyCode.KEY_K: + if (ev.ctrlKey && !ev.shiftKey && !ev.altKey && !ev.metaKey) { + dis.dispatch({ + action: 'focus_room_filter', + }); + } + break; } if (handled) { From 6547a558529faccb447f659ad7d73ebe374e764b Mon Sep 17 00:00:00 2001 From: Luke Barnard Date: Wed, 12 Jul 2017 17:12:57 +0100 Subject: [PATCH 2/2] Update to reflect previous implementation Which was originally https://github.com/vector-im/riot-web/pull/3654/commits/a74bbb424c7c07494d71329e8d4c6ef9fc37a7b9 --- src/KeyCode.js | 1 + src/components/structures/LoggedInView.js | 14 +++++++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/KeyCode.js b/src/KeyCode.js index 90c2caeb0e..ec5595b71b 100644 --- a/src/KeyCode.js +++ b/src/KeyCode.js @@ -21,6 +21,7 @@ module.exports = { ENTER: 13, SHIFT: 16, ESCAPE: 27, + SPACE: 32, PAGE_UP: 33, PAGE_DOWN: 34, END: 35, diff --git a/src/components/structures/LoggedInView.js b/src/components/structures/LoggedInView.js index 9750a2c99b..a051af5d08 100644 --- a/src/components/structures/LoggedInView.js +++ b/src/components/structures/LoggedInView.js @@ -156,13 +156,20 @@ export default React.createClass({ } */ - 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.UP: case KeyCode.DOWN: if (ev.altKey && !ev.shiftKey && !ev.ctrlKey && !ev.metaKey) { - var action = ev.keyCode == KeyCode.UP ? + let action = ev.keyCode == KeyCode.UP ? 'view_prev_room' : 'view_next_room'; dis.dispatch({action: action}); handled = true; @@ -185,10 +192,11 @@ export default React.createClass({ } break; case KeyCode.KEY_K: - if (ev.ctrlKey && !ev.shiftKey && !ev.altKey && !ev.metaKey) { + if (ctrlCmdOnly) { dis.dispatch({ action: 'focus_room_filter', }); + handled = true; } break; }