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 f1053618dc..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; @@ -184,6 +191,14 @@ export default React.createClass({ handled = true; } break; + case KeyCode.KEY_K: + if (ctrlCmdOnly) { + dis.dispatch({ + action: 'focus_room_filter', + }); + handled = true; + } + break; } if (handled) {