How to detect shift key pressed state when on mouse move

江枫思渺然 提交于 2019-11-30 22:31:23

问题


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

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

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.


回答1:


Try using the Control.ModifierKeys property:

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


来源:https://stackoverflow.com/questions/515109/how-to-detect-shift-key-pressed-state-when-on-mouse-move

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!