Skip to content

Commit

Permalink
feat: Bind Ctrl+K to the search prompt
Browse files Browse the repository at this point in the history
  • Loading branch information
polyfloyd committed Feb 18, 2024
1 parent 5748262 commit c5b3639
Showing 1 changed file with 18 additions and 11 deletions.
29 changes: 18 additions & 11 deletions src/handler/webui/view/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,25 @@ let app = createApp({
...initialData,
};
},
mounted() {
document.body.addEventListener('keypress', event => {
if (event.target != document.body) return;
// Map number keys to views.
let views = ['search', 'albums', 'genres', 'files', 'streams', 'queuer', 'player'];
let i = Object.keys(views).indexOf((event.key - 1)+'');
if (i != -1) {
this.currentView = views[i];
}
});
document.onkeydown = event => {
if (event.ctrlKey && event.key == 'k') {
event.preventDefault();
this.currentView = 'search';
}
};
},
watch: {
currentView: function(view) {
currentView(view) {
this.showNavbar = false;

let url = `${this.urlroot}player/${this.selectedPlayer}?view=${view}`;
Expand All @@ -43,13 +60,3 @@ let app = createApp({
},
});
app.mount('#app');

document.body.addEventListener('keypress', event => {
if (event.target != document.body) return;
// Map number keys to views.
let views = ['search', 'albums', 'genres', 'files', 'streams', 'queuer', 'player'];
let i = Object.keys(views).indexOf((event.key - 1)+'');
if (i != -1) {
app.currentView = views[i];
}
});

0 comments on commit c5b3639

Please sign in to comment.