diff --git a/src/librustdoc/html/render.rs b/src/librustdoc/html/render.rs
index 72a72e892814a..414c3137376a9 100644
--- a/src/librustdoc/html/render.rs
+++ b/src/librustdoc/html/render.rs
@@ -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!(
"
\
diff --git a/src/librustdoc/html/static/main.js b/src/librustdoc/html/static/main.js
index 17a940cc4c9f8..f0104c9156ded 100644
--- a/src/librustdoc/html/static/main.js
+++ b/src/librustdoc/html/static/main.js
@@ -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;
}