@@ -2,6 +2,11 @@ const MAX_SUGGESTIONS = 50;
22const MAX_SECTION_RESULTS = 3 ;
33const MAX_SUBSTRING_LIMIT = 100 ;
44
5+ // Possible states of search modal
6+ const SEARCH_MODAL_OPENED = "opened" ;
7+ const SEARCH_MODAL_CLOSED = "closed" ;
8+
9+ let SEARCH_MODAL_STATE = SEARCH_MODAL_CLOSED ;
510let TOTAL_PAGE_RESULTS = 0 ;
611let SEARCH_QUERY = "" ;
712
@@ -603,6 +608,8 @@ const showSearchModal = custom_query => {
603608 // removes previous results (if there are any).
604609 removeResults ( ) ;
605610
611+ SEARCH_MODAL_STATE = SEARCH_MODAL_OPENED ;
612+
606613 // removes the focus from the initial input field
607614 // which as already present in the docs.
608615 let search_bar = getInputField ( ) ;
@@ -634,6 +641,8 @@ const removeSearchModal = () => {
634641 // removes previous results before closing
635642 removeResults ( ) ;
636643
644+ SEARCH_MODAL_STATE = SEARCH_MODAL_CLOSED ;
645+
637646 // sets the value of input field to empty string and remove the focus.
638647 let search_outer_input = document . querySelector ( ".search__outer__input" ) ;
639648 if ( search_outer_input !== null ) {
@@ -786,6 +795,15 @@ window.addEventListener("DOMContentLoaded", evt => {
786795 }
787796 } ) ;
788797
798+ // open search modal if "forward slash" button is pressed
799+ document . addEventListener ( "keydown" , e => {
800+ if ( e . keyCode === 191 ) {
801+ if ( SEARCH_MODAL_STATE !== SEARCH_MODAL_OPENED ) {
802+ showSearchModal ( ) ;
803+ }
804+ }
805+ } ) ;
806+
789807 // if "rtd_search" is present in URL parameters,
790808 // then open the search modal and show the results
791809 // for the value of "rtd_search"
0 commit comments