feat: add key shortcuts

- 'Ctrl + a' selects all files in listing.
- 'Enter' to confirm a prompt.
This commit is contained in:
Ramires Viana
2019-12-31 16:53:35 +00:00
parent cd454bae51
commit 95316cbe8c
2 changed files with 42 additions and 2 deletions

View File

@@ -1,6 +1,6 @@
<template>
<div>
<component :is="currentComponent"></component>
<component ref="currentComponent" :is="currentComponent"></component>
<div v-show="showOverlay" @click="resetPrompts" class="overlay"></div>
</div>
</template>
@@ -46,6 +46,33 @@ export default {
}
}
},
created () {
window.addEventListener('keydown', (event) => {
if (this.show == null)
return
let prompt = this.$refs.currentComponent;
// Enter
if (event.keyCode == 13) {
switch (this.show) {
case 'delete':
prompt.submit()
break;
case 'copy':
prompt.copy(event)
break;
case 'move':
prompt.move(event)
break;
case 'replace':
prompt.showConfirm(event)
break;
}
}
})
},
computed: {
...mapState(['show', 'plugins']),
currentComponent: function () {