C# - Detecting if the SHIFT key is held when opening a context menu

后端 未结 5 2083
感情败类
感情败类 2021-01-01 08:24

In my C# application I want to display a context menu, but I want to add special options to the menu if the SHIFT key is being held down when the context menu is opened.

5条回答
  •  南笙
    南笙 (楼主)
    2021-01-01 09:23

    Use this to detect if the shift key is pressed:

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

提交回复
热议问题