FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
python-docs-theme/python_docs_theme/static/search-focus.js at main · python/python-docs-theme · GitHub
python
python-docs-theme
Repository navigation
Code
Issues
10
(10)
Pull requests
3
(3)
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
python-docs-theme
/
python_docs_theme
/
static
/
search-focus.js
Copy path
More file actions
More file actions
Latest commit
History
History
History
21 lines (19 loc) · 559 Bytes
Breadcrumbs
python-docs-theme
/
python_docs_theme
/
static
/
search-focus.js
Copy path
File metadata and controls
21 lines (19 loc) · 559 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
function
isInputFocused
(
)
{
const
activeElement
=
document
.
activeElement
;
return
(
activeElement
.
tagName
===
'INPUT'
||
activeElement
.
tagName
===
'TEXTAREA'
||
activeElement
.
isContentEditable
)
;
}
document
.
addEventListener
(
'keydown'
,
function
(
event
)
{
if
(
event
.
key
===
'/'
)
{
if
(
!
isInputFocused
(
)
)
{
// Prevent "/" from being entered in the search box
event
.
preventDefault
(
)
;
// Set the focus on the search box
const
searchBox
=
document
.
getElementById
(
'search-box'
)
;
searchBox
.
focus
(
)
;
}
}
}
)
;
Back
|
FazBrowse Home
|
New Git URL