Skip to content

armgit / dashy

Public Imported from GitHub
0

πŸš€ A self-hostable personal dashboard built for you. Includes status-checking, widgets, themes, icon packs, a UI editor and tons more!

:sparkles: Handles the launching of items using custom hotkey

Alicia Sykes23d7339be830
diff --git a/src/components/Settings/SearchBar.vue b/src/components/Settings/SearchBar.vue
index 0083c21f..160edbc3 100644
--- a/src/components/Settings/SearchBar.vue
+++ b/src/components/Settings/SearchBar.vue
@@ -18,6 +18,7 @@
<script>
import ArrowKeyNavigation from '@/utils/ArrowKeyNavigation';
+import { getCustomKeyShortcuts } from '@/utils/ConfigHelpers';
export default {
name: 'FilterTile',
@@ -28,6 +29,7 @@ export default {
return {
input: '', // Users current search term
akn: new ArrowKeyNavigation(), // Class that manages arrow key naviagtion
+ getCustomKeyShortcuts,
};
},
mounted() {
@@ -38,8 +40,11 @@ export default {
if (!this.active) return;
if (/^[a-zA-Z]$/.test(key) && currentElem !== 'filter-tiles') {
/* Letter key pressed - start searching */
- this.$refs.filter.focus();
+ if (this.$refs.filter) this.$refs.filter.focus();
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) {
/* Arrow key pressed - start navigation */
this.akn.arrowNavigation(keyCode);
@@ -61,6 +66,14 @@ export default {
document.activeElement.blur(); // Remove focus
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>