| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,10 +1,21 @@ | |||
| 1 | + function isInputFocused() { | ||
| 2 | + const activeElement = document.activeElement; | ||
| 3 | + return ( | ||
| 4 | + activeElement.tagName === 'INPUT' || | ||
| 5 | + activeElement.tagName === 'TEXTAREA' || | ||
| 6 | + activeElement.isContentEditable | ||
| 7 | + ); | ||
| 8 | + } | ||
| 9 | + | ||
| 1 | 10 | document.addEventListener('keydown', function(event) { | |
| 2 | 11 | if (event.key === '/') { | |
| 3 | - // Prevent "/" from being entered in the search box | ||
| 4 | - event.preventDefault(); | ||
| 12 | + if (!isInputFocused()) { | ||
| 13 | + // Prevent "/" from being entered in the search box | ||
| 14 | + event.preventDefault(); | ||
| 5 | 15 | ||
| 6 | - // Set the focus on the search box | ||
| 7 | - let searchBox = document.getElementById('search-box'); | ||
| 8 | - searchBox.focus(); | ||
| 16 | + // Set the focus on the search box | ||
| 17 | + const searchBox = document.getElementById('search-box'); | ||
| 18 | + searchBox.focus(); | ||
| 19 | + } | ||
| 9 | 20 | } | |
| 10 | 21 | }); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments