WinForms - Capturing the combination of key presses using ProcessCmdKey VS KeyDown

后端 未结 2 970
孤城傲影
孤城傲影 2020-12-06 14:13

My goal is to implement a custom Control + S key press handler to wire up to a custom save method in a winforms app.

There are several ways to accomplish this based

相关标签:
2条回答
  • 2020-12-06 14:43

    I solved this by doing,

    if(e.KeyData==(Keys.S | Keys.Control))
    
    0 讨论(0)
  • 2020-12-06 14:48

    Set the KeyPreview property of our form to true. The summary of this property says: "Gets or sets a value indicating whether the form will receive key events before the event is passed to the control that has focus.". Then use the KeyUp event. Unless KeyPressed it gives also information on special keys like control keys.

    0 讨论(0)
提交回复
热议问题