如何在VB.NET中检测多个修饰键和非修饰键的组合? [英] How to detect combination of multiple modifier and non-modifier keys in VB.NET?
本文介绍了如何在VB.NET中检测多个修饰键和非修饰键的组合?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我尝试过为这个问题提供不同的解决方案,但似乎无法解决.我想在VB.Net的KeyDown
事件中检测到 Shift Ctrl C .
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.
对于我的表单,KeyPreview
属性设置为true.
The KeyPreview
property is set to true for my form.
我尝试过的是:
If e.Modifiers = (Keys.Shift And Keys.Control) And e.KeyCode = Keys.C Then
'do the action
End If
任何帮助将不胜感激!
推荐答案
对您的问题的评论正确:
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
如果您希望在表单上的任何地方进行此操作,则需要将Form
的KeyPreview
放入True
.
If you would like this to happen anywhere on your form, you need to put the KeyPreview
of your Form
to True
.
然后您可以将其放入Form_KeyDown
这篇关于如何在VB.NET中检测多个修饰键和非修饰键的组合?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文