Skip to content

Commit

Permalink
Add option to disable keyboard shortcuts in docs
Browse files Browse the repository at this point in the history
  • Loading branch information
GuillaumeGomez committed Oct 21, 2019
1 parent 14f0ed6 commit 8774484
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/librustdoc/html/render.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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'>\
Expand Down
3 changes: 2 additions & 1 deletion src/librustdoc/html/static/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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;
}

Expand Down

0 comments on commit 8774484

Please sign in to comment.