vue实现快捷键

created() {
let arr = [];
let that = this;
document.onkeydown = function(e) {
if(arr.length > 0) { // a-z按键长按去重
if(arr.indexOf(e.key.toLowerCase()) >= 0) {
return
}
}
arr.push(e.key.toLowerCase())
this.keydown = arr.join('+');
if(this.keydown == 'shift+enter') {
this.keydown = '';
that.combineFile()
}
}
document.onkeyup = function (e) {
arr.splice(arr.indexOf( e.key.toLowerCase() ),1);
this.keydown = arr.join('+');
}
this.keydown = '';
}

  

 

posted @ 2018-09-26 15:36  寒筱洱  阅读(9383)  评论(0编辑  收藏  举报