Skip to content

Commit a0af9ef

Browse files
committed
BugFix: Handling '/' keystrokes on input fixed
1 parent aaa7063 commit a0af9ef

2 files changed

Lines changed: 11 additions & 2 deletions

File tree

.DS_Store

6 KB
Binary file not shown.

content.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,20 @@
11
let isEnabled = false;
22

33
function handleKeydown(event) {
4+
// Check if the focused element is an input field or a textarea
5+
var focusedElement = document.activeElement;
6+
var isTyping = focusedElement.tagName === 'INPUT' || focusedElement.tagName === 'TEXTAREA';
7+
8+
// If the user is typing in an input field or a textarea, do not override the key
9+
if (isTyping) {
10+
return;
11+
}
12+
413
if (event.key === '/' && isEnabled) {
5-
event.preventDefault();
14+
event.preventDefault(); // Prevent the default action
615
var searchBars = document.querySelectorAll('input[type="search"], input[type="text"]');
716
if (searchBars.length > 0) {
8-
searchBars[0].focus();
17+
searchBars[0].focus(); // Focus on the first search bar found
918
}
1019
}
1120
}

0 commit comments

Comments
 (0)