diff --git a/core/src/views/UnifiedSearch.vue b/core/src/views/UnifiedSearch.vue index 2adf818b1816e..1fc0800130763 100644 --- a/core/src/views/UnifiedSearch.vue +++ b/core/src/views/UnifiedSearch.vue @@ -20,6 +20,7 @@ import NcButton from '@nextcloud/vue/dist/Components/NcButton.js' import Magnify from 'vue-material-design-icons/Magnify.vue' import UnifiedSearchModal from './UnifiedSearchModal.vue' +import logger from '../logger.js' export default { name: 'UnifiedSearch', @@ -34,7 +35,11 @@ export default { } }, mounted() { - console.debug('Unified search initialized!') + logger.info('Unified search initialized!') + window.addEventListener('keydown', this.handleKeyDown) + }, + beforeDestroy() { + window.removeEventListener('keydown', this.handleKeyDown) }, methods: { toggleUnifiedSearch() { @@ -43,6 +48,16 @@ export default { handleModalVisibilityChange(newVisibilityVal) { this.showUnifiedSearch = newVisibilityVal }, + handleKeyDown(event) { + // if not already opened, allows us to trigger default browser on second keydown + if (event.ctrlKey && event.code === 'KeyF' && !this.showUnifiedSearch) { + event.preventDefault() + this.showUnifiedSearch = true + } else if (event.ctrlKey && event.key === 'f' && this.showUnifiedSearch) { + // User wants to use the native browser search, so we close ours again + this.showUnifiedSearch = false + } + }, }, }