How to detect combination of multiple modifier and non-modifier keys in VB.NET?

╄→尐↘猪︶ㄣ 提交于 2019-12-24 15:33:11

问题


I have tried different solutions given here for the question, but couldn't seem to get around it. I want to detect ShiftCtrlC in a KeyDown event in VB.Net.

The KeyPreview property is set to true for my form.

What I tried is:

If e.Modifiers = (Keys.Shift And Keys.Control) And e.KeyCode = Keys.C Then
    'do the action
End If

Any help would be much appreciated!


回答1:


The comment to your question is correct:

If (e.KeyCode = Keys.C AndAlso e.Modifiers = (Keys.Control Or Keys.Shift)) Then
    'Do what you want here
End If

If you would like this to happen anywhere on your form, you need to put the KeyPreview of your Form to True.

You can then put it in the Form_KeyDown



来源:https://stackoverflow.com/questions/30397987/how-to-detect-combination-of-multiple-modifier-and-non-modifier-keys-in-vb-net

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!