user docs: Dynamically replace keyboard shortcuts for Mac OS.

This commit is contained in:
Cynthia Lin 2017-12-22 21:11:25 -08:00 committed by showell
parent 2691c27126
commit d449fcb309
3 changed files with 40 additions and 13 deletions

View File

@ -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, '<code>' + key + '</code>');
});
$(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 () {

View File

@ -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.

View File

@ -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.