You need to listen to the contextmenu
event. This is triggered when the context menu should be shown. So either if the right mouse butten or or ctrl + mouse.
If it is not supported then you can try to check the mousedown
event where button
is 2
and ctrlKey
is true
if it is triggered by using ctrl + mouse
document.addEventListener("contextmenu",function(event){
});
OR (depending on what the browser supports)
document.addEventListener("mousedown",function(event){
if( event.ctrlKey || event.button == 2 ) {
}
});
edit: removed the which
info
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…