Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/362.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
jQuery/JavaScript是一种检测是否正在使用除鼠标左键或右键之外的任何其他键的可能方法_Javascript_Jquery - Fatal编程技术网

jQuery/JavaScript是一种检测是否正在使用除鼠标左键或右键之外的任何其他键的可能方法

jQuery/JavaScript是一种检测是否正在使用除鼠标左键或右键之外的任何其他键的可能方法,javascript,jquery,Javascript,Jquery,我对jQuery/JavaScript还相当陌生,我一直在试图弄清楚是否有可能检测到我网站上的用户是否在使用除鼠标右键/左键之外的任何其他键。如果有人有任何想法将是有益的 是的,这是可能的。阅读有关键盘事件的信息:谢谢,我会调查的! $(document).keydown('keypress', function(e) { alert("keyboard is using right now") }); $(document).mousedown('keypress', func

我对jQuery/JavaScript还相当陌生,我一直在试图弄清楚是否有可能检测到我网站上的用户是否在使用除鼠标右键/左键之外的任何其他键。如果有人有任何想法将是有益的

是的,这是可能的。阅读有关键盘事件的信息:

谢谢,我会调查的!
$(document).keydown('keypress', function(e) {
        alert("keyboard is using right now")
});
$(document).mousedown('keypress', function(e) {
    if(e.which==1)
        alert("left is using right now")
        if(e.which==3)
        alert("right is using right now")
        if(e.which==2)
        alert("middle is using right now")
});