Skip to content

Commit 053a7e7

Browse files
authored
Merge pull request godotengine#8568 from Calinou/search-fix-slash-shortcut
Fix `/` keyboard shortcut to allow typing `/` within the search field
2 parents 6566441 + 04020f1 commit 053a7e7

File tree

3 files changed

+12
-30
lines changed

3 files changed

+12
-30
lines changed

_static/js/algolia.js

Lines changed: 0 additions & 27 deletions
This file was deleted.

_static/js/custom.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,17 @@ $(document).ready(() => {
246246
Documentation.hideSearchWords();
247247
}
248248

249+
window.addEventListener('keydown', function(event) {
250+
if (event.key === '/') {
251+
var searchField = document.querySelector('#rtd-search-form input[type=text]');
252+
if (document.activeElement !== searchField) {
253+
searchField.focus();
254+
searchField.select();
255+
event.preventDefault();
256+
}
257+
}
258+
});
259+
249260
// Initialize handlers for page scrolling and our custom sidebar.
250261
const mediaQuery = window.matchMedia('only screen and (min-width: 769px)');
251262

conf.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -217,9 +217,7 @@
217217
html_css_files.append("css/dev.css")
218218

219219
html_js_files = [
220-
"js/custom.js?6", # Increment the number at the end when the file changes to bust the cache.
221-
('https://cdn.jsdelivr.net/npm/docsearch.js@2/dist/cdn/docsearch.min.js', {'defer': 'defer'}),
222-
('js/algolia.js', {'defer': 'defer'})
220+
"js/custom.js?7", # Increment the number at the end when the file changes to bust the cache.
223221
]
224222

225223
# Output file base name for HTML help builder

0 commit comments

Comments
 (0)