You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
- 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();
- }
- }
- });
|