var hasTouch = window.matchMedia('(pointer: coarse)').matches; if(hasTouch ){ //touch事件 }else{ //鼠标事件 }