function runOnKeys(func, ...codeN){
let pressed = [];
window.onkeydown = function(e){
pressed.push(e.which);
for(let i = 0; i<codeN.length; i++){
console.log(codeN);
console.log(pressed)
if(!(codeN[i] in pressed)) return false;
}
alert();
}
window.onkeyup = function(e){
delete pressed[e.which] ;
}
}
runOnKeys(
function() { alert("Привет!") },
"Q".charCodeAt(0),
"W".charCodeAt(0)
);
function runOnKeys(func, ...codeN){
var pressed = [];
window.onkeydown = function(e){
pressed.push(e.which);
for(var i = 0; i<codeN.length; i++){
if(pressed.indexOf(codeN[i]) == -1) return false;
}
func();
pressed = [];
}
window.onkeyup = function(e){
pressed = [];
}
}
runOnKeys(
function() { alert("Привет!") },
"Q".charCodeAt(0),
"W".charCodeAt(0)
);