element-ui/examples/components/theme-configurator/shortcut.vue

27 lines
488 B
Vue
Raw Permalink Normal View History

2021-06-07 11:56:04 +08:00
<script>
export default {
data() {
return {
downloading: false
};
},
methods: {
shortcut(e) {
if (e.keyCode === 90 && (e.ctrlKey || e.metaKey)) {
if (e.shiftKey) {
this.redo();
} else {
this.undo();
}
}
},
enableShortcut() {
document.addEventListener('keydown', this.shortcut);
},
disableShortcut() {
document.removeEventListener('keydown', this.shortcut);
}
}
};
</script>