Skip to content

Commit

Permalink
Merge pull request #94 from FutureProofHomes/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
that1guy authored Jan 22, 2025
2 parents d20a4d2 + f29e62a commit 3be0225
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
35 changes: 35 additions & 0 deletions docs/javascript/keyboard_shortcuts_fix.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
(() => {
function event_handler(event) {
event.stopPropagation();
}

// Function to disable MkDocs Material keyboard shortcuts
function disableKeyboardShortcuts() {
document.addEventListener('keydown', event_handler, true);
console.log('Keyboard Shortcuts disabled 🖖')
}

// Function to enable MkDocs Material keyboard shortcuts
function enableKeyboardShortcuts() {
document.removeEventListener('keydown', event_handler, true);
console.log('Keyboard Shortcuts enabled')
}

// Create a MutationObserver to watch for changes in the document
const observer = new MutationObserver(() => {
const installDialog = document.querySelector('body > ewt-install-dialog');

if (installDialog) {
// If the install dialog is present, disable keyboard shortcuts
disableKeyboardShortcuts();
} else {
// If the install dialog is not present, enable keyboard shortcuts
enableKeyboardShortcuts();
}
});

document.addEventListener('DOMContentLoaded', () => {
// Start observing the document body for child additions/removals
observer.observe(document.body, { childList: true });
});
})()
1 change: 1 addition & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ plugins:
extra_javascript:
# - javascript/installer.js
- javascript/esp-web-tools/install-button.js
- javascript/keyboard_shortcuts_fix.js
# - https://cdn.jsdelivr.net/npm/esp-web-tools@10/dist/web/install-button.js?module

copyright: |
Expand Down

0 comments on commit 3be0225

Please sign in to comment.