File tree Expand file tree Collapse file tree 2 files changed +27
-1
lines changed Expand file tree Collapse file tree 2 files changed +27
-1
lines changed Original file line number Diff line number Diff line change @@ -541,7 +541,7 @@ <h1>Clippy Lints</h1>
541541 < div class ="col-12 col-md-5 search-control ">
542542 < div class ="input-group ">
543543 < label class ="input-group-addon " id ="filter-label " for ="search-input "> Filter:</ label >
544- < input type ="text " class ="form-control filter-input " placeholder ="Keywords or search string " id ="search-input "
544+ < input type ="text " class ="form-control filter-input " placeholder ="Keywords or search string (`S` or `/` to focus) " id ="search-input "
545545 ng-model ="search " ng-blur ="updatePath() " ng-keyup ="$event.keyCode == 13 && updatePath() "
546546 ng-model-options ="{debounce: 50} " />
547547 < span class ="input-group-btn ">
Original file line number Diff line number Diff line change @@ -579,6 +579,32 @@ function setTheme(theme, store) {
579579 }
580580}
581581
582+ function handleShortcut ( ev ) {
583+ if ( ev . ctrlKey || ev . altKey || ev . metaKey ) {
584+ return ;
585+ }
586+
587+ if ( document . activeElement . tagName === "INPUT" ) {
588+ if ( ev . key === "Escape" ) {
589+ document . activeElement . blur ( ) ;
590+ }
591+ } else {
592+ switch ( ev . key ) {
593+ case "s" :
594+ case "S" :
595+ case "/" :
596+ ev . preventDefault ( ) ; // To prevent the key to be put into the input.
597+ document . getElementById ( "search-input" ) . focus ( ) ;
598+ break ;
599+ default :
600+ break ;
601+ }
602+ }
603+ }
604+
605+ document . addEventListener ( "keypress" , handleShortcut ) ;
606+ document . addEventListener ( "keydown" , handleShortcut ) ;
607+
582608// loading the theme after the initial load
583609const prefersDark = window . matchMedia ( "(prefers-color-scheme: dark)" ) ;
584610const theme = localStorage . getItem ( 'clippy-lint-list-theme' ) ;
You can’t perform that action at this time.
0 commit comments