diff --git a/frontend_tests/node_tests/hotkey.js b/frontend_tests/node_tests/hotkey.js index ffb24e026e..582d9a8981 100644 --- a/frontend_tests/node_tests/hotkey.js +++ b/frontend_tests/node_tests/hotkey.js @@ -70,12 +70,13 @@ run_test('mappings', () => { }); } - function map_down(which, shiftKey, ctrlKey, metaKey) { + function map_down(which, shiftKey, ctrlKey, metaKey, altKey) { return hotkey.get_keydown_hotkey({ which: which, shiftKey: shiftKey, ctrlKey: ctrlKey, metaKey: metaKey, + altKey: altKey, }); } @@ -124,6 +125,7 @@ run_test('mappings', () => { assert.equal(map_down(75, true, true), undefined); // shift + ctrl + k assert.equal(map_down(83, true, true), undefined); // shift + ctrl + s assert.equal(map_down(219, true, true, false), undefined); // shift + ctrl + [ + assert.equal(map_down(83, false, false, false, true), undefined); // alt + s // 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"; @@ -135,6 +137,8 @@ run_test('mappings', () => { assert.equal(map_down(83, false, true, false), undefined); // ctrl + s // Reset userAgent global.navigator.userAgent = ''; + + assert.equal(map_down(83, false, true, false, true).name, 'narrow_starred'); // ctrl + alt + s }); run_test('basic_chars', () => { diff --git a/static/js/hotkey.js b/static/js/hotkey.js index cff08d9ac0..fc68dae7a8 100644 --- a/static/js/hotkey.js +++ b/static/js/hotkey.js @@ -111,13 +111,23 @@ var keypress_mappings = { 120: {name: 'compose_private_message', message_view_only: true}, // 'x' }; +var keydown_ctrl_alt_mappings = { + 83: {name: 'narrow_starred', message_view_only: true}, // 's' +}; + exports.get_keydown_hotkey = function (e) { + var hotkey; + if (e.altKey) { + if (e.ctrlKey) { + hotkey = keydown_ctrl_alt_mappings[e.which]; + if (hotkey) { + return hotkey; + } + } return; } - var hotkey; - if (e.ctrlKey && !e.shiftKey) { hotkey = keydown_ctrl_mappings[e.which]; if (hotkey) { @@ -626,6 +636,10 @@ exports.process_hotkey = function (e, hotkey) { return do_narrow_action(function (target, opts) { narrow.by('is', 'private', opts); }); + case 'narrow_starred': + return do_narrow_action(function (target, opts) { + narrow.by('is', 'starred', opts); + }); case 'query_streams': stream_list.initiate_search(); return true; diff --git a/templates/zerver/app/keyboard_shortcuts.html b/templates/zerver/app/keyboard_shortcuts.html index eb50371366..1ffafed986 100644 --- a/templates/zerver/app/keyboard_shortcuts.html +++ b/templates/zerver/app/keyboard_shortcuts.html @@ -170,6 +170,10 @@