JS修改键
shiftKey 按下shift键,为true,默认为false
altKey
ctrlKey
metaKey windows系统 按下windows(开始)键,为true
macos系统 按下command键,为true
【注】 和别的操作进行组合,形成一些快捷键操作
例:
window.onload = function(){
document.onmousedown = function(ev){
var e = ev || window.event;
var arr = [];
if(e.shiftKey){
arr.push("shift");
}
if(e.altKey){
arr.push("alt");
}
if(e.ctrlKey){
arr.push("ctrl");
}
if(e.metaKey){
arr.push("window");
}
alert(arr);
}
}