It was not a good idea to have the hotkey
fallthrough the `case` for user not being in message list.
We merge both the cases and also remove `M` from
`message_view_only_keys`.
Earlier, keyboard shortcuts were not supported for non-latin
keyboard layouts.
This commit adds support for it.
Keyboard can be:
* configured to type latin text, with the QWERTY, AZERTY, etc layout.
* configured to type non-latin text.
For non-latin users, if a shortcut requires a key and it is not
present on the keyboard, they press the same physical key that a
QWERTY user would press.
Pressing QWERTY equivalent key is not a Zulip specific requirement,
non-latin users have confirmed in CZO that they use the same behaviour
on other applications.
Algorithm:
We need to determine the key combination pressed in a consistent way,
irrespective of the keyboard layout.
For keyboard layouts (e.g. QWERTY) where `event.key` results in
printable ASCII characters or named key attribute values like "Tab",
"Enter", etc., we use `event.key` directly to determine the key
combination.
For layouts where the character defined for a hotkey can't be typed
directly (e.g. 'a' in Cyrillic), users press the same physical key
combination that a QWERTY user would use (e.g. 'ф' on Cyrillic maps
to 'a' on QWERTY). In such cases, we derive the key combination
(QWERTY equivalent) using `event.code` and the `CODE_TO_QWERTY_CHAR`
map.
Here `event` is "keydown" event.
Once, the key combination is determined the action to perform is
executed.
Fixes: #19605.
Earlier, with Caps Lock enabled, pressing letters like 'a', 'i', etc
resulted in the keyboard shortcuts for 'Shift+A', 'Shift+I', etc
getting executed. Ideally, they should work only when 'Shift + Key'
is pressed.
We used to check capitalized letters, which can result either due
to `key` pressed with Caps Lock enabled or `Shift + key` pressed.
This commit fixes the bug by using the event modifiers states to
construct a fully descriptive string like 'Cmd+Ctrl+Alt+Shift+A',
and then look up that string in a single mapping for further execution.
We treat a-z letters case-insensitively. We distinguish between
'a' and 'A' as 'A' vs 'Shift+A'.
This descriptive string approach also resolves a bug where
`Ctrl + Meta + C/K/S/.` was working. We define the valid hotkey as
`Meta + C/K/S/.` for macOS and `Ctrl + C/K/S/.` for others.
This commit removes the deprecated `keypress` event.
Now, we use the `keydown` event to handle all the cases.
Earlier, we used `keypress` because it allowed us to distinguish
between lowercase and uppercase characters using `event.which`.
For example:
* For 'r':
* keypress.which = 114
* keydown.which = 82
* For 'R':
* keypress.which = 82
* keydown.which = 82
As shown, `keydown.which` cannot distinguish between 'r' and 'R',
which is why `keypress` was helpful.
Now, modern browsers support `event.key` on `keydown`, which directly
gives 'r' or 'R' as needed. This makes `keypress` unnecessary, and
we can safely rely on `keydown` with `event.key` to get the exact
character.
An earlier commit in this PR #34570, in which we replaced
the `event.which` with `event.key` plays a major role as a prep
commit to help removing `keypress` event in this commit.
Earlier, 'H' and 'N' were being tested as unmapped keys and the test
was falsely passing because these keys are handled by `process_keydown`
but the test was processing it with `process_keypress`.
This commit removes those keys from the test.
We already test them with keydown in other tests.
The `keydown` and `keypress` event handlers defined in `hotkey.js`
were using `event.which`, which is deprecated.
This commit makes changes to use `event.key` instead.
As a side effect, it fixes a small bug where both `Alt+P` and
`Alt+Shift+P` could be used to toggle preview mode. Only `Alt+P`
is the defined shortcut for that.
In f768d3330b, the node test
written was a noop because "e" hotkey is handled by `keypress`
instead of `keydown`. So, the expected codepath was never getting
executed at all.
This commit fixes the test.
Previously, when in anonymous login, pressing the "view original
message" button showed the original message and allowed copying it.
However, the corresponding keyboard shortcut ('e') did not work as
expected and a login pop-up appeared instead.
Now, by fixing the UI features' permissions for anonymous users, by
adding "edit_message" as a feature they can perform, they are allowed
to use the 'e' keyboard shortcut as intended.
Fixes#33838
Earlier, if pm_list or stream_list was zoomed in and hitting `q`
hotkey would seemingly do nothing but in the background would add
highlighted class to `stream_row` and toggle stream-list-filter.
This commit fixes this behaviour by bringing focus to currently
visible input filter field.
This commit replaces the spectrum color picker used in the stream
popover and stream settings with a custom color picker popover, which
contains a grid of predefined color swatches and a custom color option.
The custom color option uses the HTML5 <input type="color"> which shows
the native browser color picker UI.
Fixes#14961.
Forward message starts a new message with the quoted context
(message or selection).
The compose box opens with then channel picker open and no topic.
Also added documentation about this feature in the help center.
Fixes part 2 of #31953