diff options
author | 2024-02-20 09:10:51 +0100 | |
---|---|---|
committer | 2024-02-21 20:02:58 -0800 | |
commit | facf38955c2512add9d8a59a70a0ade3921235b2 (patch) | |
tree | e6698ed6604c004feb92507a4f33a410a00315bc /internal/ui/static/js/keyboard_handler.js | |
parent | cfdb890eae2b1090e0b43090e4e4d3007e0b94d8 (diff) | |
download | v2-facf38955c2512add9d8a59a70a0ade3921235b2.tar.gz v2-facf38955c2512add9d8a59a70a0ade3921235b2.tar.zst v2-facf38955c2512add9d8a59a70a0ade3921235b2.zip |
Add 'Enter' key as a hotkey to open selected item
There are a few things that need to be done, to make this work.
First, we need to register `Enter` as another hotkey that opens the
selected item.
However, by default the `KeyboardHandler` will override all default
actions. That might make sense for any other key, but for the `Enter`
key, we want to keep the default behavior (i.e. follow a selected link
or press a button). So for this single key event, we do not call
`preventDefault()`.
I see this as unproblematic for the following reasons.
1. With the changes from #2348, when we're in a list of items (articles,
categories, feeds), there is no link selected. This is what made the
`Enter` key work _implicitly_ in the past. With nothing selected, the
`Enter` key will do nothing by default.
2. If we have **any** link selected (including when we are in a view
with a list of selectable items), we'll get the default action of
`Enter` (i.e. follow a link), which is exactly what we had before.
Lastly, we need to update the list of keyboard shortcuts displayed when
pressing `?`.
This fixes #2366.
Diffstat (limited to 'internal/ui/static/js/keyboard_handler.js')
-rw-r--r-- | internal/ui/static/js/keyboard_handler.js | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/internal/ui/static/js/keyboard_handler.js b/internal/ui/static/js/keyboard_handler.js index 037f9949..3459db5d 100644 --- a/internal/ui/static/js/keyboard_handler.js +++ b/internal/ui/static/js/keyboard_handler.js @@ -17,7 +17,11 @@ class KeyboardHandler { return; } - event.preventDefault(); + if (key != "Enter") + { + event.preventDefault(); + } + this.queue.push(key); for (let combination in this.shortcuts) { |