Test if the Ctrl key is down using C#

后端 未结 6 1239
一整个雨季
一整个雨季 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 10:59

    This isn't really an answer to the question at hand, but I needed to do this in a console application and the detail was a little different.

    I had to add references to WindowsBase and PresentationFramework, and at that point I could do:

    if (System.Windows.Input.Keyboard.Modifiers == ModifierKeys.Control)
       blah
    

    Just adding this here in case someone else is doing something similar.

提交回复
热议问题