Skip to content

Commit

Permalink
Rollup merge of rust-lang#65656 - GuillaumeGomez:option-disable-short…
Browse files Browse the repository at this point in the history
…cut, r=Dylan-DPC

Add option to disable keyboard shortcuts in docs

Fixes rust-lang#65211.

r? @Manishearth
  • Loading branch information
JohnTitor authored Oct 22, 2019
2 parents 304ce88 + 8774484 commit 21af776
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 21af776

Please sign in to comment.