diff --git a/src/librustdoc/html/static/js/main.js b/src/librustdoc/html/static/js/main.js
index 789e7d298fa..c33e2727744 100644
--- a/src/librustdoc/html/static/js/main.js
+++ b/src/librustdoc/html/static/js/main.js
@@ -419,7 +419,8 @@ function loadCss(cssFileName) {
return;
}
- if (document.activeElement.tagName === "INPUT") {
+ if (document.activeElement.tagName === "INPUT" &&
+ document.activeElement.type !== "checkbox") {
switch (getVirtualKey(ev)) {
case "Escape":
handleEscape(ev);
diff --git a/src/test/rustdoc-gui/settings.goml b/src/test/rustdoc-gui/settings.goml
index a43c712ef9a..49478775b05 100644
--- a/src/test/rustdoc-gui/settings.goml
+++ b/src/test/rustdoc-gui/settings.goml
@@ -122,6 +122,7 @@ click: ".setting-line:last-child .toggle .label"
assert-local-storage: {"rustdoc-disable-shortcuts": "true"}
// Make sure that "Disable keyboard shortcuts" actually took effect.
+// The help popover won't exist yet.
press-key: "?"
wait-for-css: ("#settings-menu .popover", {"display": "block"})