shortcut.vue 488 B

123456789101112131415161718192021222324252627
  1. <script>
  2. export default {
  3. data() {
  4. return {
  5. downloading: false
  6. };
  7. },
  8. methods: {
  9. shortcut(e) {
  10. if (e.keyCode === 90 && (e.ctrlKey || e.metaKey)) {
  11. if (e.shiftKey) {
  12. this.redo();
  13. } else {
  14. this.undo();
  15. }
  16. }
  17. },
  18. enableShortcut() {
  19. document.addEventListener('keydown', this.shortcut);
  20. },
  21. disableShortcut() {
  22. document.removeEventListener('keydown', this.shortcut);
  23. }
  24. }
  25. };
  26. </script>