Problem
The ? keyboard shortcut (Help menu) intercepts the keypress globally. It is a "breaking" issue for Rust by Example because typing the ? operator is required for many of the code exercises (error handling).
Currently, if you are solving a "Todo" in the embedded editor and try to use the ? operator, the help popup opens and the character is never inserted into the code.
Expected Behavior
Shortcuts should be suppressed if the focus is within an editable element, including inputs, textareas, or contenteditable containers used by code editors.
Steps
- Open any Rust by Example page with an exercise (e.g., Hello World).
- Click into the interactive code block to edit.
- Try to type
?.
- Result: The Help modal opens; the editor remains unchanged and the character is not typed.
Possible Solution(s)
The keydown listener in book.js needs a guard clause to check the event target before calling e.preventDefault().
// Suggested guard at the start of the keydown handler
const target = e.target;
const isEditable = target.tagName === 'INPUT' ||
target.tagName === 'TEXTAREA' ||
target.isContentEditable ||
(target.closest && target.closest('.ace_editor'));
if (isEditable) { return; }
### Notes
* **Environment:** Affects all mdBook sites with interactive elements. Reproducible on Chrome/Firefox/Safari.
* **Willingness to contribute:** I have the fix ready and can submit a PR if this issue is confirmed.
### Version
```text
0.5.2
Problem
The
?keyboard shortcut (Help menu) intercepts the keypress globally. It is a "breaking" issue for Rust by Example because typing the?operator is required for many of the code exercises (error handling).Currently, if you are solving a "Todo" in the embedded editor and try to use the
?operator, the help popup opens and the character is never inserted into the code.Expected Behavior
Shortcuts should be suppressed if the focus is within an editable element, including inputs, textareas, or
contenteditablecontainers used by code editors.Steps
?.Possible Solution(s)
The
keydownlistener inbook.jsneeds a guard clause to check the event target before callinge.preventDefault().