其他分享
首页 > 其他分享> > 快捷键操作

快捷键操作

作者:互联网

public async mounted() {
const that = this as any;
document.addEventListener("keydown", this.WindowKeyDown);
}

  

  destroyed() {
    this.removeEventListenerkeydown();
  }

  

  public removeEventListenerkeydown() {
    document.removeEventListener("keydown", this.WindowKeyDown);
  }

  

  public async WindowKeyDown(e) {
    let that = this as any;
    let data = that.$data;
    if (e && e.keyCode == 27) { // 按 Esc      //要做的事情            
 
       //   this.closeForm();  //关闭
    }
    if (e.keyCode == 67 && (navigator.platform.match("Mac") ? e.metaKey : e.ctrlKey)) {
   
      // this.resetForm('zyjs_accept_preget'); //清空
    }
    if (e.keyCode == 69 && (navigator.platform.match("Mac") ? e.metaKey : e.ctrlKey)) {
 
      //     this.clickOutPut(); //
    }
    if (e.keyCode == 81 && (navigator.platform.match("Mac") ? e.metaKey : e.ctrlKey)) {
      e.preventDefault();   //ctrl+Q
      this.submit();
    }
  }

  

标签:快捷键,WindowKeyDown,metaKey,&&,ctrlKey,操作,navigator,keyCode
来源: https://www.cnblogs.com/LFxanla/p/12254643.html