Catching Ctrl + C in a textbox

后端 未结 8 1723
孤城傲影
孤城傲影 2020-12-15 20:42

Despite me working with C# (Windows Forms) for years, I\'m having a brain fail moment, and can\'t for the life of me figure out how to catch a user typing Ctrl +

8条回答
  •  -上瘾入骨i
    2020-12-15 21:19

    Key events occur in the following order:

    1. KeyDown
    2. KeyPress
    3. KeyUp

    The KeyPress event is not raised by noncharacter keys; however, the noncharacter keys do raise the KeyDown and KeyUp events. Control is a noncharacter key.

    You can check with this line of code: if (e.KeyData == (Keys.Control | Keys.C))

提交回复
热议问题