Merge pull request #24 from samuelthomas2774/master
Add keyboard shortcut
This commit is contained in:
commit
1f46323dc9
|
@ -10,17 +10,32 @@
|
|||
|
||||
const methods = { showSettings, hideSettings };
|
||||
|
||||
let globalKeyListener;
|
||||
|
||||
export default {
|
||||
components,
|
||||
methods,
|
||||
data() {
|
||||
return { active: false }
|
||||
return {
|
||||
active: false,
|
||||
platform: global.process.platform
|
||||
}
|
||||
},
|
||||
created: function() {
|
||||
window.addEventListener('keyup', e => {
|
||||
if (e.which !== 27) return;
|
||||
this.hideSettings();
|
||||
created: function () {
|
||||
window.addEventListener('keyup', globalKeyListener = e => {
|
||||
if (this.active && e.which === 27) {
|
||||
this.hideSettings();
|
||||
return;
|
||||
}
|
||||
if (!e.metaKey && !e.ctrlKey && e.key !== 'b') return;
|
||||
|
||||
!this.active ? this.showSettings() : this.hideSettings();
|
||||
|
||||
e.stopImmediatePropagation();
|
||||
});
|
||||
},
|
||||
destroyed: function () {
|
||||
if (globalKeyListener) window.removeEventListener('keyup', globalKeyListener);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
</script>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<div class="bd-settings-wrapper" :class="{active: active}">
|
||||
<div class="bd-settings-wrapper" :class="[{active: active}, 'platform-' + this.platform]">
|
||||
<div class="bd-settings-button" :class="{active: active}" @click="showSettings">
|
||||
<div class="bd-settings-button-btn"></div>
|
||||
</div>
|
||||
<BdSettings :active="active" :close="hideSettings"/>
|
||||
</div>
|
||||
</div>
|
||||
|
|
Loading…
Reference in New Issue