about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2020-11-12 10:28:15 +0000
committerbors <bors@rust-lang.org>2020-11-12 10:28:15 +0000
commit12f0dba618e761c987142474435dff95ab177f3c (patch)
treeed1d86f0db4769d43426f06141889ab71474989e
parent55794e43960ad3647e78ea5b0cb5ad0c5c0596a8 (diff)
parent8b20e9b47847d911c2eed11f1471c99b898ac932 (diff)
downloadrust-12f0dba618e761c987142474435dff95ab177f3c.tar.gz
rust-12f0dba618e761c987142474435dff95ab177f3c.zip
Auto merge of #78773 - GuillaumeGomez:theme-picker-shortcut, r=jyn514
Add shortcut for theme picker menu

Follow-up of #78584

Just like you can focus the search input by pressing "S", you can now access the theme picker menu by pressing "T" and navigate through the options only using the keyboard.

cc `@notriddle`

r? `@jyn514`
-rw-r--r--src/librustdoc/html/static/main.js10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/librustdoc/html/static/main.js b/src/librustdoc/html/static/main.js
index de4792a5bd2..10342679cf4 100644
--- a/src/librustdoc/html/static/main.js
+++ b/src/librustdoc/html/static/main.js
@@ -415,6 +415,15 @@ function defocusSearchBar() {
                 displayHelp(true, ev);
                 break;
 
+            case "t":
+            case "T":
+                displayHelp(false, ev);
+                ev.preventDefault();
+                var themePicker = getThemePickerElement();
+                themePicker.click();
+                themePicker.focus();
+                break;
+
             default:
                 var themePicker = getThemePickerElement();
                 if (themePicker.parentNode.contains(ev.target)) {
@@ -2852,6 +2861,7 @@ function defocusSearchBar() {
         var shortcuts = [
             ["?", "Show this help dialog"],
             ["S", "Focus the search field"],
+            ["T", "Focus the theme picker menu"],
             ["↑", "Move up in search results"],
             ["↓", "Move down in search results"],
             ["↹", "Switch tab"],