]> git.lizzy.rs Git - rust.git/commitdiff
Add option to disable keyboard shortcuts in docs
authorGuillaume Gomez <guillaume1.gomez@gmail.com>
Mon, 21 Oct 2019 09:36:52 +0000 (11:36 +0200)
committerGuillaume Gomez <guillaume1.gomez@gmail.com>
Mon, 21 Oct 2019 09:36:52 +0000 (11:36 +0200)
src/librustdoc/html/render.rs
src/librustdoc/html/static/main.js

index 72a72e892814a97e88507a11d7d7a3b8620b0ba6..414c3137376a95f2d45c1dc7c12090aa9508a2f1 100644 (file)
@@ -1241,6 +1241,7 @@ fn settings(root_path: &str, suffix: &str) -> String {
         ("go-to-only-result", "Directly go to item in search if there is only one result",
             false),
         ("line-numbers", "Show line numbers on code examples", false),
+        ("disable-shortcuts", "Disable keyboard shortcuts", false),
     ];
     format!(
 "<h1 class='fqn'>\
index 17a940cc4c9f8adb26058db6f1d3c6bb59e60cd7..f0104c9156ded8b9ba93effd5bf223cf4c72acf8 100644 (file)
@@ -79,6 +79,7 @@ function getSearchElement() {
                      "derive",
                      "traitalias"];
 
+    var disableShortcuts = getCurrentValue("rustdoc-disable-shortcuts") !== "true";
     var search_input = getSearchInput();
 
     // On the search screen, so you remain on the last tab you opened.
@@ -294,7 +295,7 @@ function getSearchElement() {
 
     function handleShortcut(ev) {
         // Don't interfere with browser shortcuts
-        if (ev.ctrlKey || ev.altKey || ev.metaKey) {
+        if (ev.ctrlKey || ev.altKey || ev.metaKey || disableShortcuts === true) {
             return;
         }