Add ctrl+F keyboard shortcut to focus on Search

This commit is contained in:
Bubka 2023-02-08 16:05:45 +01:00
parent d3bc99f328
commit 07608917fb

View File

@ -67,7 +67,7 @@
<!-- search -->
<div role="search" class="field">
<div class="control has-icons-right">
<input id="txtSearch" type="search" tabindex="1" :aria-label="$t('commons.search')" :title="$t('commons.search')" class="input is-rounded is-search" v-model="search">
<input ref="searchBox" id="txtSearch" type="search" tabindex="1" :aria-label="$t('commons.search')" :title="$t('commons.search')" class="input is-rounded is-search" v-model="search">
<span class="icon is-small is-right">
<font-awesome-icon :icon="['fas', 'search']" v-if="!search" />
<button tabindex="1" :title="$t('commons.clear_search')" class="clear-selection delete" v-if="search" @click="search = '' "></button>
@ -332,6 +332,8 @@
mounted() {
document.addEventListener('keydown', this.keyListener)
// we don't have to fetch fresh data so we try to load them from localstorage to avoid display latency
if( !this.toRefresh && !this.$route.params.isFirstLoad ) {
const accounts = this.$storage.get('accounts', null) // use null as fallback if localstorage is empty
@ -351,6 +353,10 @@
},
destroyed () {
document.removeEventListener('keydown', this.keyListener)
},
components: {
Modal,
OtpDisplayer,
@ -629,6 +635,19 @@
this.accounts.sort((a, b) => a.service < b.service ? 1 : -1)
this.saveOrder()
},
/**
*
*/
keyListener : function(e) {
if (e.key === "f" && (e.ctrlKey || e.metaKey)) {
e.preventDefault();
const searchBox = document.getElementById('txtSearch');
if (searchBox != undefined) {
searchBox.focus()
}
}
},
}
};