feat: Add keyboard shortcuts for search input focus and selection

This commit is contained in:
Will Miao
2025-04-13 13:12:32 +08:00
parent 0b11e6e6d0
commit 5918f35b8b

View File

@@ -29,6 +29,7 @@ export class SearchManager {
this.initEventListeners();
this.loadSearchPreferences();
this.setupKeyboardShortcuts();
updatePanelPositions();
@@ -36,6 +37,26 @@ export class SearchManager {
window.addEventListener('resize', updatePanelPositions);
}
// Add this new method to setup keyboard shortcuts
setupKeyboardShortcuts() {
// Add global keyboard shortcut listener for Ctrl+F or Cmd+F
document.addEventListener('keydown', (e) => {
// Check for Ctrl+F (Windows/Linux) or Cmd+F (Mac)
if ((e.ctrlKey || e.metaKey) && e.key === 'f') {
// Prevent default browser search behavior
e.preventDefault();
// Focus the search input if it exists
if (this.searchInput) {
this.searchInput.focus();
// Optionally select all text in the search input for easy replacement
this.searchInput.select();
}
}
});
}
initEventListeners() {
// Search input event
if (this.searchInput) {