mirror of https://github.com/Lissy93/dashy.git
✨ Handles the launching of items using custom hotkey
This commit is contained in:
parent
5c3667003a
commit
23d7339be8
|
@ -18,6 +18,7 @@
|
||||||
<script>
|
<script>
|
||||||
|
|
||||||
import ArrowKeyNavigation from '@/utils/ArrowKeyNavigation';
|
import ArrowKeyNavigation from '@/utils/ArrowKeyNavigation';
|
||||||
|
import { getCustomKeyShortcuts } from '@/utils/ConfigHelpers';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'FilterTile',
|
name: 'FilterTile',
|
||||||
|
@ -28,6 +29,7 @@ export default {
|
||||||
return {
|
return {
|
||||||
input: '', // Users current search term
|
input: '', // Users current search term
|
||||||
akn: new ArrowKeyNavigation(), // Class that manages arrow key naviagtion
|
akn: new ArrowKeyNavigation(), // Class that manages arrow key naviagtion
|
||||||
|
getCustomKeyShortcuts,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
|
@ -38,8 +40,11 @@ export default {
|
||||||
if (!this.active) return;
|
if (!this.active) return;
|
||||||
if (/^[a-zA-Z]$/.test(key) && currentElem !== 'filter-tiles') {
|
if (/^[a-zA-Z]$/.test(key) && currentElem !== 'filter-tiles') {
|
||||||
/* Letter key pressed - start searching */
|
/* Letter key pressed - start searching */
|
||||||
this.$refs.filter.focus();
|
if (this.$refs.filter) this.$refs.filter.focus();
|
||||||
this.userIsTypingSomething();
|
this.userIsTypingSomething();
|
||||||
|
} else if (/^[0-9]$/.test(key)) {
|
||||||
|
/* Number key pressed, check if user has a custom binding */
|
||||||
|
this.handleHotKey(key);
|
||||||
} else if (keyCode >= 37 && keyCode <= 40) {
|
} else if (keyCode >= 37 && keyCode <= 40) {
|
||||||
/* Arrow key pressed - start navigation */
|
/* Arrow key pressed - start navigation */
|
||||||
this.akn.arrowNavigation(keyCode);
|
this.akn.arrowNavigation(keyCode);
|
||||||
|
@ -61,6 +66,14 @@ export default {
|
||||||
document.activeElement.blur(); // Remove focus
|
document.activeElement.blur(); // Remove focus
|
||||||
this.akn.resetIndex(); // Reset current element index
|
this.akn.resetIndex(); // Reset current element index
|
||||||
},
|
},
|
||||||
|
handleHotKey(key) {
|
||||||
|
const usersHotKeys = this.getCustomKeyShortcuts();
|
||||||
|
usersHotKeys.forEach((hotkey) => {
|
||||||
|
if (hotkey.hotkey === parseInt(key, 10)) {
|
||||||
|
if (hotkey.url) window.open(hotkey.url, '_blank');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
Loading…
Reference in New Issue