Test if the Ctrl key is down using C#

后端 未结 6 1251
一整个雨季
一整个雨季 2020-12-01 09:59

I have a form that the user can double click on with the mouse and it will do something. Now I want to be able to know if the user is also holding the Ctrl key do

6条回答
  •  醉话见心
    2020-12-01 11:01

    The same soneone said above, but comparing as different than zero, which should be a little faster and use less instructions on most architectures:

    public static bool IsControlDown()
    {
        return (Control.ModifierKeys & Keys.Control) != 0;
    }
    

提交回复
热议问题