Rollup merge of #65656 - GuillaumeGomez:option-disable-shortcut, r=Dylan-DPC

Add option to disable keyboard shortcuts in docs

Fixes #65211.

r? @Manishearth
This commit is contained in:
Yuki Okushi 2019-10-23 17:14:37 +09:00 committed by GitHub
commit 88e3ae2eb4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 1 deletions

View 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'>\

View 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;
}