最新消息:20210917 已从crifan.com换到crifan.org

【已解决】C#中在获得鼠标点击事件时,如何判断Control键,Shift键被按下

C# crifan 3080浏览 0评论

【问题】

在C#的窗体程序中,获得鼠标点击的事件时,想要得知当前是否有Control键,Shift键等是否被按下。

【解决过程】

1. 网上找了下,最后实现的参考代码如下:

private void xxx_MouseClick(object sender, MouseEventArgs e)
{
    if ((Control.ModifierKeys & Keys.Control) == Keys.Control)// CTRL is pressed
    {

    }
    
    if ((Control.ModifierKeys & Keys.Shift) == Keys.Shift)
    {
    
    }
}

转载请注明:在路上 » 【已解决】C#中在获得鼠标点击事件时,如何判断Control键,Shift键被按下

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
92 queries in 0.190 seconds, using 23.33MB memory