vue组合快捷键

vue组合快捷键

mounted(){
	//监听键盘
	document.removeEventListener('keydown',this.keydownfun);
}
methods:{
	keydownfun(e){
		if(e.keyCode=='116'){
			return false;
		}
		// console.log(e.srcElement)
		if(e.srcElement.nodeName=="INPUT" || e.srcElement.nodeName == "TEXTAREA"){
			if(e.srcElement.type){
				if(e.srcElement.type!='checkbox' && e.srcElement.type!='radio'){
					return false;
				}
			}else{
				return false;
			} 
		}
		if(e.srcElement.nodeName=='DIV'){
			let ids=e.srcElement.id;
			if(ids && ids=="textdivakaaka"){
				return false;
			}
		}
		if(e.srcElement.id=="textdivakaaka"){
			e.preventDefault();
			return false;
		}
		let jsonarrakaaka=[
			{actions:'上一条报文',shortcut:'↑'},
			{actions:'下一条报文',shortcut:'↓'},
			{actions:'抄报',shortcut:'Enter'},
			{actions:'抄报保存',shortcut:'Enter+s'},
			{actions:'批注',shortcut:'Shift+enter'},
			{actions:'报文导出',shortcut:'ctrl+alt+S'},
			{actions:'报文下载',shortcut:'ctrl+shift+S'},
			{actions:'快进',shortcut:'→'},
			{actions:'快退',shortcut:'←'},
			{actions:'图片放大',shortcut:'ctrl++'},
			{actions:'图片缩小',shortcut:'ctrl+-'},
			{actions:'图片翻转',shortcut:'ctrl+p'},
			{actions:'简繁切换',shortcut:'ctrl+alt+shift'},
		];
		let jsonarr=this.jsonarrakaarr?JSON.parse(this.jsonarrakaarr) : jsonarrakaaka;
		jsonarr.forEach((val) =>{
			if(val.shortcut.indexOf('++')!=-1){
				val.shortcut=val.shortcut.replace('++', '+akaaka');
				val.shortcut=val.shortcut.toLocaleLowerCase().split('+');
				val.shortcut=val.shortcut.join().replace('akaaka','+').split(',');
			}else{
				val.shortcut=val.shortcut.toLocaleLowerCase().split('+');
			}
		})
		let thats=this;
		if(e.keyCode !== 116){
			e.preventDefault();
		}
		
		let keydownar=[];
		if(e.ctrlKey){
			keydownar.push('ctrl');
		}
		if(e.shiftKey){
			keydownar.push('shift');
		}
		if(e.altKey){
			keydownar.push('alt');
		}
		for(let i=0;i

你可能感兴趣的:(vue,vue.js,javascript)