Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit23f0b42

Browse files
committed
Focus search box when pressing slash
1 parent1a4022a commit23f0b42

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

‎python_docs_theme/layout.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ <h3>{{ _('Navigation') }}</h3>
4848
{%- if builder != "htmlhelp" %}
4949
<divclass="inline-search"role="search">
5050
<formclass="inline-search"action="{{ pathto('search') }}"method="get">
51-
<inputplaceholder="{{ _('Quick search') }}"aria-label="{{ _('Quick search') }}"type="search"name="q"/>
51+
<inputplaceholder="{{ _('Quick search') }}"aria-label="{{ _('Quick search') }}"type="search"name="q"id="search-box"/>
5252
<inputtype="submit"value="{{ _('Go') }}"/>
5353
</form>
5454
</div>
@@ -76,6 +76,7 @@ <h3>{{ _('Navigation') }}</h3>
7676
{%- if not embedded %}
7777
<scripttype="text/javascript"src="{{ pathto('_static/copybutton.js', 1) }}"></script>
7878
<scripttype="text/javascript"src="{{ pathto('_static/menu.js', 1) }}"></script>
79+
<scripttype="text/javascript"src="{{ pathto('_static/search-focus.js', 1) }}"></script>
7980
<scripttype="text/javascript"src="{{ pathto('_static/themetoggle.js', 1) }}"></script>
8081
{%- endif -%}
8182
{%- endif -%}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
document.addEventListener('keydown',function(event){
2+
if(event.key==='/'){
3+
// Prevent "/" from being entered in the search box
4+
event.preventDefault();
5+
6+
// Set the focus on the search box
7+
letsearchBox=document.getElementById('search-box');
8+
searchBox.focus();
9+
}
10+
});

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp