diff --git a/static/js/portico/help.js b/static/js/portico/help.js index 92ab98d29b..c5e4d16182 100644 --- a/static/js/portico/help.js +++ b/static/js/portico/help.js @@ -29,12 +29,44 @@ function highlight_current_article() { article.addClass('highlighted'); } +function adjust_mac_shortcuts() { + var keys_map = new Map([ + ['Backspace', 'Delete'], + ['Enter', 'Return'], + ['Home', 'Fn + ⇽'], + ['End', 'Fn + ⇾'], + ['PgUp', 'Fn + ↑'], + ['PgDn', 'Fn + ↓'], + ]); + + $(".markdown .content code").each(function () { + var text = $(this).text(); + + if (!keys_map.has(text)) { + return; + } + + var key_string = keys_map.get(text); + var keys = key_string.match(/[^\s\+]+/g); + + _.each(keys, function (key) { + key_string = key_string.replace(key, '' + key + ''); + }); + + $(this).replaceWith(key_string); + }); +} + function render_code_sections() { $(".code-section").each(function () { registerCodeSection($(this)); }); highlight_current_article(); + + if (/Mac/i.test(navigator.userAgent)) { + adjust_mac_shortcuts(); + } } (function () { diff --git a/templates/zerver/help/getting-started-with-zulip.md b/templates/zerver/help/getting-started-with-zulip.md index 0a34b07d8d..8c9e7395b1 100644 --- a/templates/zerver/help/getting-started-with-zulip.md +++ b/templates/zerver/help/getting-started-with-zulip.md @@ -55,4 +55,4 @@ Once you've figured out the basics, you'll probably want to: interest. - Master Zulip's [keyboard shortcuts](/help/keyboard-shortcuts). Anything you can do with the mouse, you can do even faster from the keyboard. Start - with `n`, `↓`, `c`, and `Enter` (`Return`), and use `?` for help. + with `n`, `↓`, `c`, and `Enter`, and use `?` for help. diff --git a/templates/zerver/help/keyboard-shortcuts.md b/templates/zerver/help/keyboard-shortcuts.md index b9415c1933..37a8de466e 100644 --- a/templates/zerver/help/keyboard-shortcuts.md +++ b/templates/zerver/help/keyboard-shortcuts.md @@ -13,11 +13,6 @@ below, and add more to your repertoire as needed. * [Menus](#menus) * [Streams settings](#streams-settings-page) -!!! warn "" - Replace `Enter` with `Return` if using a Mac keyboard. - - Other Mac shortcuts are shown in parentheses when different. - ## The basics * **Reply to message**: `r` or `Enter` — Reply to the selected @@ -35,7 +30,7 @@ below, and add more to your repertoire as needed. * **Next message**: `↓` or `j` -* **Last message**: `End` (`Fn` + `⇾`) or `G` — Also marks all messages in +* **Last message**: `End` or `G` — Also marks all messages in the current view as read. * **Next unread topic**: `n` @@ -54,18 +49,18 @@ below, and add more to your repertoire as needed. * **Search people**: `w` -* **Last message**: `End` (`Fn` + `⇾`) or `G` — Also marks all messages in +* **Last message**: `End` or `G` — Also marks all messages in the current view as read. -* **First message**: `Home` (`Fn` + `⇽`) +* **First message**: `Home` * **Previous message**: `↑` or `k` * **Next message**: `↓` or `j` -* **Scroll up**: `PgUp` (`Fn` + `↑`) or `K` +* **Scroll up**: `PgUp` or `K` -* **Scroll down**: `PgDn` (`Fn` + `↓`), `J`, or `Spacebar` +* **Scroll down**: `PgDn`, `J`, or `Spacebar` ## Narrowing @@ -83,7 +78,7 @@ below, and add more to your repertoire as needed. ## Composing messages -* **Reply to message**: `r` or `Enter` (`Return`) — Reply to the selected +* **Reply to message**: `r` or `Enter` — Reply to the selected message (outlined in blue). Same behavior as clicking on the message. * **Reply to message, mentioning author**: `@` @@ -140,7 +135,7 @@ title="thumbs up"/>**: `+` * **Edit selected draft**: `Enter` -* **Delete selected draft**: `Backspace` (`Delete`) +* **Delete selected draft**: `Backspace` Keyboard navigation (e.g. arrow keys) works as expected.