Skip to content

Commit

Permalink
add keyboard input to browser. first draft. likely to remove from pyt…
Browse files Browse the repository at this point in the history
…hon because no maintained lib avail.
  • Loading branch information
mgineer85 committed Apr 21, 2024
1 parent ef1949c commit 7eb1f2f
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
41 changes: 41 additions & 0 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@ export default defineComponent({
console.log('app created, waiting for stores to init first dataset');
this.init();
console.log('data initialization finished');
window.addEventListener('keyup', this.keyUpHandler);
},
unmounted() {
window.removeEventListener('keyup', this.keyUpHandler);
},
methods: {
async init() {
Expand Down Expand Up @@ -165,6 +170,42 @@ export default defineComponent({
console.error('Failed make initial SSE connection!', err);
});
},
keyUpHandler(e) {
// Your handler code here
if (this.uiSettingsStore.uiSettings.keyboard_input_enabled) {
switch (e.key) {
case this.uiSettingsStore.uiSettings.keyboard_input_keycode_takepic: {
console.log('browser keyboard trigger 1pic');
remoteProcedureCall('/api/processing/chose/1pic');
break;
}
case this.uiSettingsStore.uiSettings.keyboard_input_keycode_takecollage: {
console.log('browser keyboard trigger 1pic');
remoteProcedureCall('/api/processing/chose/collage');
break;
}
case this.uiSettingsStore.uiSettings.keyboard_input_keycode_takeanimation: {
console.log('browser keyboard trigger 1pic');
remoteProcedureCall('/api/processing/chose/animation');
break;
}
case this.uiSettingsStore.uiSettings.keyboard_input_keycode_takevideo: {
console.log('browser keyboard trigger 1pic');
remoteProcedureCall('/api/processing/chose/video');
break;
}
case this.uiSettingsStore.uiSettings.keyboard_input_keycode_print_recent_item: {
console.log('browser keyboard trigger print latest');
remoteProcedureCall('/api/print/latest');
break;
}
default: {
console.info(`key "${e.key}" not assigned`);
}
}
}
},
},
});
</script>
7 changes: 7 additions & 0 deletions src/stores/ui-settings-store.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,13 @@ export const useUiSettingsStore = defineStore('ui-settings-store', {
gallery_show_download: null,
gallery_show_delete: null,
gallery_show_print: null,

keyboard_input_enabled: null,
keyboard_input_keycode_takepic: null,
keyboard_input_keycode_takecollage: null,
keyboard_input_keycode_takeanimation: null,
keyboard_input_keycode_takevideo: null,
keyboard_input_keycode_print_recent_item: null,
},

storeState: STATES.INIT,
Expand Down

0 comments on commit 7eb1f2f

Please sign in to comment.