Add option to disable keyboard shortcuts in docs
This commit is contained in:
parent
14f0ed64e3
commit
87744841c8
2 changed files with 3 additions and 1 deletions
|
@ -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",
|
("go-to-only-result", "Directly go to item in search if there is only one result",
|
||||||
false),
|
false),
|
||||||
("line-numbers", "Show line numbers on code examples", false),
|
("line-numbers", "Show line numbers on code examples", false),
|
||||||
|
("disable-shortcuts", "Disable keyboard shortcuts", false),
|
||||||
];
|
];
|
||||||
format!(
|
format!(
|
||||||
"<h1 class='fqn'>\
|
"<h1 class='fqn'>\
|
||||||
|
|
|
@ -79,6 +79,7 @@ function getSearchElement() {
|
||||||
"derive",
|
"derive",
|
||||||
"traitalias"];
|
"traitalias"];
|
||||||
|
|
||||||
|
var disableShortcuts = getCurrentValue("rustdoc-disable-shortcuts") !== "true";
|
||||||
var search_input = getSearchInput();
|
var search_input = getSearchInput();
|
||||||
|
|
||||||
// On the search screen, so you remain on the last tab you opened.
|
// On the search screen, so you remain on the last tab you opened.
|
||||||
|
@ -294,7 +295,7 @@ function getSearchElement() {
|
||||||
|
|
||||||
function handleShortcut(ev) {
|
function handleShortcut(ev) {
|
||||||
// Don't interfere with browser shortcuts
|
// Don't interfere with browser shortcuts
|
||||||
if (ev.ctrlKey || ev.altKey || ev.metaKey) {
|
if (ev.ctrlKey || ev.altKey || ev.metaKey || disableShortcuts === true) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue