diff --git a/frontend_tests/node_tests/hotkey.js b/frontend_tests/node_tests/hotkey.js index 6ef705dfa2..d70b7cba06 100644 --- a/frontend_tests/node_tests/hotkey.js +++ b/frontend_tests/node_tests/hotkey.js @@ -99,7 +99,7 @@ function stubbing(func_name_to_stub, test_function) { assert.equal(map_press(106).name, 'vim_down'); // j assert.equal(map_down(219, false, true).name, 'escape'); // ctrl + [ - assert.equal(map_down(75, false, true).name, 'search'); // ctrl + k + assert.equal(map_down(75, false, true).name, 'search_with_k'); // ctrl + k // More negative tests. assert.equal(map_down(47), undefined); @@ -124,7 +124,7 @@ function stubbing(func_name_to_stub, test_function) { // CMD tests for MacOS global.navigator.userAgent = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.167 Safari/537.36"; assert.equal(map_down(219, false, false, true).name, 'escape'); // cmd + [ - assert.equal(map_down(75, false, false, true).name, 'search'); // cmd + k + assert.equal(map_down(75, false, false, true).name, 'search_with_k'); // cmd + k assert.equal(map_down(75, false, true, false), undefined); // ctrl + k diff --git a/static/js/hotkey.js b/static/js/hotkey.js index a5767d25e7..e6321fbb3b 100644 --- a/static/js/hotkey.js +++ b/static/js/hotkey.js @@ -48,7 +48,7 @@ var keydown_unshift_mappings = { }; var keydown_cmd_or_ctrl_mappings = { - 75: {name: 'search', message_view_only: false}, // 'K' + 75: {name: 'search_with_k', message_view_only: false}, // 'K' 219: {name: 'escape', message_view_only: false}, // '[' }; @@ -555,6 +555,8 @@ exports.process_hotkey = function (e, hotkey) { var height = $("#compose-textarea")[0].scrollHeight; $("#compose-textarea").caret(Infinity).animate({ scrollTop: height }, "fast"); return true; + } else if (event_name === "search_with_k") { + // Do nothing; this allows one to use ctrl+k inside compose. } else { // Let the browser handle the key normally. return false; @@ -616,6 +618,7 @@ exports.process_hotkey = function (e, hotkey) { activity.initiate_search(); return true; case 'search': + case 'search_with_k': search.initiate_search(); return true; case 'gear_menu':