我正在抓一个MouseDown
控件上的事件,这给了我一个MouseEventArgs
签名中的对象。现在我希望能够判断用户在单击时是否按住了“Shift”或“Control”键。但是MouseEventArgs
对象不包含任何键盘信息!
What's the easiest way of telling whether the keyboard Shift/Ctrl keys were being held at the time of the click?
使用 Control.ModifierKeys 属性查看按下的内容。例如:
private void Form1_MouseClick(object sender, MouseEventArgs e) {
if (Control.ModifierKeys == Keys.Control) {
Console.WriteLine("Ctrl+Click");
}
}
其他修饰符有Keys.Alt
and Keys.Shift
。寻找组合,例如,(Keys.Control | Keys.Shift)
.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)