同时按下鼠标左键和右键 [英] Simultaneous pressing of left and right mouse buttons

查看:193
本文介绍了同时按下鼠标左键和右键的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,


我正在尝试检测我的IE6用户是否同时按下了我的Javascript代码中的鼠标左键和/ b
使用:


if(event.button == 3){alert("左右鼠标按键

按下);}


我在mousedown或mouseup事件上调用上面的代码。


但它似乎不起作用。 :,(


即使同时按下左右两个

按钮,if条件也不满足。


有什么东西我不见了吗?


最好,

震撼

Hi there,

I am trying to detect whether my IE6 users have pressed both right and
left mouse buttons simultaneously in my Javascript code, by using:

if(event.button==3) {alert("Both right and left mouse buttons
pressed");}

I am calling the above code on mousedown or mouseup events.

But it does not seem to work. :,(

The if condition is not satisfied even on pressing the left and right
buttons simultaneously.

Is there something that I am missing?

Best,
Shocky

推荐答案

Shocky写于27 okt 2007 comp.lang.javascript
Shocky wrote on 27 okt 2007 in comp.lang.javascript:

我试图检测是否我的IE6用户在我的Javascript代码中同时按下了右键和鼠标左键,使用:


if(event.button == 3){alert (按下鼠标右键和左键

按下);}


我在mousedown或mouseup事件上调用上面的代码。


但它似乎不起作用。:,(


即使按下左右也不满足if条件

按钮同时。


有什么东西我不见了吗?
I am trying to detect whether my IE6 users have pressed both right and
left mouse buttons simultaneously in my Javascript code, by using:

if(event.button==3) {alert("Both right and left mouse buttons
pressed");}

I am calling the above code on mousedown or mouseup events.

But it does not seem to work. :,(

The if condition is not satisfied even on pressing the left and right
buttons simultaneously.

Is there something that I am missing?



是的。<试试看:


< button onmousedown =''alert(event.button)''>

测试下来< / button>

< br>< br>

< button onmouseup =''alert(event.button); return false;' '>

测试< / button>


你看,你不能同时按下它们。


-

Evertjan。

荷兰。

(请将x''es更改为我的电子邮件地址中的点数)

Yes.

Try it out:

<button onmousedown=''alert(event.button)''>
Test down</button>
<br><br>
<button onmouseup=''alert(event.button);return false;''>
Test up</button>

You see, you won''t be able to press them simulaniously.

--
Evertjan.
The Netherlands.
(Please change the x''es to dots in my emailaddress)


Shocky写道:
Shocky wrote:

我试图检测我的IE6用户是否同时按下了<和br />
在我的Javascript代码中同时使用鼠标左键,使用:


if(event.button == 3){alert("左右两只鼠标)按钮

按下);}


我在mousedown或mouseup事件上调用上面的代码。


但它似乎没有用。 :,(


即使同时按下左右两个

按钮,if条件也不满足。


有什么我缺少的东西吗?
I am trying to detect whether my IE6 users have pressed both right and
left mouse buttons simultaneously in my Javascript code, by using:

if(event.button==3) {alert("Both right and left mouse buttons
pressed");}

I am calling the above code on mousedown or mouseup events.

But it does not seem to work. :,(

The if condition is not satisfied even on pressing the left and right
buttons simultaneously.

Is there something that I am missing?



我的测试表明event.button == 3要求事件类型为

` mousemove''。

http: //msdn2.microsoft.com/en-us/library/ms533544.aspx

PointedEars

-

"使用任何版本的Microsoft Frontpage来创建您的网站。(这不会是b $ b阻止人们查看您的来源,但没有人会想要窃取它。)"

- 来自< http://www.vortex-webdesign.com/help/hidesource.htm>

My tests indicate that event.button == 3 requires the event type to be
`mousemove''.

http://msdn2.microsoft.com/en-us/library/ms533544.aspx
PointedEars
--
"Use any version of Microsoft Frontpage to create your site. (This won''t
prevent people from viewing your source, but no one will want to steal it.)"
-- from <http://www.vortex-webdesign.com/help/hidesource.htm>


文章< Xn ***** ***************@194.109.133.242> ;,Evertjan。< ex ************** @ interxnl.netwrote:
In article <Xn********************@194.109.133.242>, "Evertjan." <ex**************@interxnl.netwrote:

> Shocky wr ote on 27 okt 2007 in comp.lang.javascript

>我试图检测我的IE6用户是否同时按下了和我的Javascript代码中同时使用鼠标左键,使用:
>I am trying to detect whether my IE6 users have pressed both right and
left mouse buttons simultaneously in my Javascript code, by using:



[snip]

[snip]


>
你看,你不可能同时按下它们。
>
You see, you won''t be able to press them simulaniously.



是和否。虽然几乎不可能同时按下两个按钮

,但是当然可以按下一个,然后另一个按下,而没有释放第一个按钮。在我看来,OP需要在相反的按钮上查找两个连续的
mousedown事件,而没有干预鼠标事件。


-

问候,

Doug Miller(在milmac dot com上的alphageek)


现在是时候把他们所有的该死的茶扔在港口了再次。

Yes and no. While it''s nearly impossible to press the two buttons exactly
simultaneously, it''s certainly possible to press one, then the other, without
releasing the first. Seems to me that the OP needs to look for two consecutive
mousedown events, on opposite buttons, without an intervening mouseup event.

--
Regards,
Doug Miller (alphageek at milmac dot com)

It''s time to throw all their damned tea in the harbor again.


这篇关于同时按下鼠标左键和右键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆