mirror of
https://github.com/zulip/zulip.git
synced 2025-11-05 22:43:42 +00:00
hotkey: Correct Mac equivalent of Alt and handle exceptions separately.
Though the correct mapping for Alt in Mac is Option, we had so far been mapping it to Command, since for the 2 pre-existing shortcuts that used Alt, Command was the only key that worked on Mac. However, these are exceptions. Now we map Alt to Option, and handle the 2 exceptions separately, using data attributes on those shortcut elements. This is a prep commit for introducing a hotkey that uses Alt / Option.
This commit is contained in:
@@ -45,7 +45,7 @@ const keys_map = new Map([
|
||||
["PgUp", "↑"],
|
||||
["PgDn", "↓"],
|
||||
["Ctrl", "⌘"],
|
||||
["Alt", "⌘"],
|
||||
["Alt", "⌥"],
|
||||
]);
|
||||
|
||||
const fn_shortcuts = new Set(["Home", "End", "PgUp", "PgDn"]);
|
||||
@@ -69,7 +69,12 @@ export function adjust_mac_kbd_tags(kbd_elem_class: string): void {
|
||||
$(this).addClass("arrow-key");
|
||||
}
|
||||
|
||||
const replace_key = keys_map.get(key_text);
|
||||
// We use data-mac-key attribute to override the default key in case
|
||||
// of exceptions. Currently, there are 2 shortcuts (for navigating back
|
||||
// and forth in browser history) which need `Cmd` instead of the expected
|
||||
// mapping (`Opt`) for the `Alt` key, so we use this attribute to override
|
||||
// `Opt` with `Cmd`.
|
||||
const replace_key = $(this).attr("data-mac-key") ?? keys_map.get(key_text);
|
||||
if (replace_key !== undefined) {
|
||||
key_text = replace_key;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user