Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to disable keyboard shortcuts in docs #65656

Merged
merged 1 commit into from
Oct 23, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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