Skip to content

Commit

Permalink
BugFix: Handling '/' keystrokes on input fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
prashanth-up committed Dec 29, 2023
1 parent aaa7063 commit a0af9ef
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
Binary file added .DS_Store
Binary file not shown.
13 changes: 11 additions & 2 deletions content.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
let isEnabled = false;

function handleKeydown(event) {
// Check if the focused element is an input field or a textarea
var focusedElement = document.activeElement;
var isTyping = focusedElement.tagName === 'INPUT' || focusedElement.tagName === 'TEXTAREA';

// If the user is typing in an input field or a textarea, do not override the key
if (isTyping) {
return;
}

if (event.key === '/' && isEnabled) {
event.preventDefault();
event.preventDefault(); // Prevent the default action
var searchBars = document.querySelectorAll('input[type="search"], input[type="text"]');
if (searchBars.length > 0) {
searchBars[0].focus();
searchBars[0].focus(); // Focus on the first search bar found
}
}
}
Expand Down

0 comments on commit a0af9ef

Please sign in to comment.