如何在鼠标移动时检测shift键pressed状态 [英] How to detect shift key pressed state when on mouse move

查看:185
本文介绍了如何在鼠标移动时检测shift键pressed状态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想显示的图像放大叠加时,鼠标和shift键pressed。

I'm trying to show a zoomed in overlay on an image when mouse over and shift key pressed.

问题是,用户可能有pressed shift键之前甚至窗口具有焦点,所以的KeyDown监测并不是一个解决方案。

The problem is that user might have pressed the shift key before even the window has focus, so KeyDown monitoring is not a solution.

有没有办法在鼠标事件进入修改键的状态? 在Java中,例如鼠标事件包含标志组合键,不是那么.NET。

Is there a way to access modifier key states during mouse events? In Java for example the mouse event contains flags for modifier keys, not so in .NET.

推荐答案

尝试使用<一个href="http://msdn.microsoft.com/en-us/library/system.windows.forms.control.modifierkeys.aspx">Control.ModifierKeys属性:

if ((Control.ModifierKeys & Keys.Shift) != Keys.None)
{
    // do my stuff
}

这篇关于如何在鼠标移动时检测shift键pressed状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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