快捷键操作

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();
    }
  }

  

上一篇:(5)Appium手机操作-针对手机常用设置功能进行操作


下一篇:event对象的onkeydown使用