搭建自己的base.js(2)-其他事件方法

來源:互聯網
上載者:User

標籤:blog   io   java   ar   資料   div   cti   log   on   

擷取滑鼠按鍵
// 擷取滑鼠按鍵,getButton:function(event) {//DOM,先檢測是否支援DOM滑鼠事件if(document,implementation.hasFeature("MouseEvents","2.0")) {return event.button; //0主鍵,1滾輪,2次鍵} else {  //IE8及之前switch(event.button) {case 0:case 1:case 3:case 5:case 7:return 0;  //都按下了主鍵,有些結合其他鍵同時按case 2:case 6:return 2;  //次鍵case 4:return 1;  //滾輪}}},
  擷取滾輪滾動差
// 擷取滑鼠滾輪getWheelDelta:function(event) {if(event.wheelDelta) {return (event.wheelDelta);  //120的倍數,滾輪向上滾為正,IE,Chrome} else {//firefox方向相反,且滾一次是3的倍數return -event.detail * 40;  }},
  擷取鍵盤編碼
// 擷取鍵盤編碼getCharCode:function(event) {if(typeof event.charCode == ‘number‘) {return event.charCode;  //IE9,Firefox,Chrome} else {return event.keyCode;  //IE8}},
  擷取剪下板文本
// 擷取剪下板文本getClipboardText:function(event) {//IE儲存在window中,var clipboardData = (event.clipboardData || window.clipboardData);return clipboardData.getData(‘text‘);},
  設定剪下板內容
// 設定剪下板內容setClipboardText:function(event,value) {if(event.clipboardData) {//Chrome,Safari,設定成功返回true,text/plan為資料類型return event.clipboardData.setData(‘text/plain‘,value);  } else if (window.clipboardData) {return window.clipboardData.setData(‘text‘,value);  //IE}}

  

搭建自己的base.js(2)-其他事件方法

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.