mirror of
https://github.com/twbs/bootstrap.git
synced 2025-08-22 13:13:03 +02:00
Add keyboard shortcut to focus search field (#31702)
* Documentation: Add slash key event to focus the input search. * Add little tag for keyboard shortcut in the search field * Use ctrl / as keyboard shortcut * Update search.js Co-authored-by: chuckrincon <chuckrincon@gmail.com> Co-authored-by: Patrick H. Lauke <redux@splintered.co.uk> Co-authored-by: XhmikosR <xhmikosr@gmail.com>
This commit is contained in:
@@ -12,6 +12,13 @@
|
||||
var inputElement = document.getElementById('search-input')
|
||||
var siteDocsVersion = inputElement.getAttribute('data-docs-version')
|
||||
|
||||
document.addEventListener('keydown', function (event) {
|
||||
if (event.ctrlKey && event.key === '/') {
|
||||
event.preventDefault()
|
||||
inputElement.focus()
|
||||
}
|
||||
})
|
||||
|
||||
function getOrigin() {
|
||||
var location = window.location
|
||||
var origin = location.origin
|
||||
|
Reference in New Issue
Block a user