如何使用C#多个修饰键 [英] How to use multiple modifier keys in C#
问题描述
我使用的是keydown事件检测键pressed并有各种操作的几个组合键。
如果(e.Key code == Keys.C&放大器;&安培; e.Modifiers == Keys.Control&放大器;&安培; e.Modifiers == Keys.Shift )
{
//做工作
}
否则,如果(e.Key code == Keys.V&放大器;&安培; e.Modifiers == Keys.Control)
{
//糊
}
由于某些原因,关键的组合,其中我打<大骨节病>控制骨节病> + <大骨节病>移骨节病> + <大骨节病> C 骨节病>不工作。我已经重新命令他们,并把它放在顶部想这可能是自干扰<大骨节病>控制骨节病> + <大骨节病> C 骨节病>,甚至删除了<大骨节病>控制骨节病> + C ,看看它是否是造成一个问题。它仍然无法正常工作。我知道这可能是一些非常简单的,但不能完全掌握它是什么。我所有的1 +修饰1组合键的做工精细,只要我添加第二个修改是当它不再起作用。
如果(e.Key code == Keys.C&放大器;&安培; e.Modifiers ==( Keys.Control | Keys.Shift))
{
//做工作
}
否则,如果(e.Key code == Keys.V&放大器;&安培; e.Modifiers == Keys.Control)
{
//糊
}
I am using a keydown event to detect keys pressed and have several key combinations for various operations.
if (e.KeyCode == Keys.C && e.Modifiers == Keys.Control && e.Modifiers == Keys.Shift)
{
//Do work
}
else if (e.KeyCode == Keys.V && e.Modifiers == Keys.Control)
{
//Paste
}
For some reason the key combination in which I hit Ctrl + Shift + C is not working. I have re ordered them, and placed it at the top thinking it might be interference from the Ctrl + C, and even removed the Ctrl + C to see if it was causing a problem. It still does not work. I know it's probably something very simple, but can't quite grasp what it is. All of my 1 modifier + 1 key combination's work fine, as soon as I add a second modifier is when it no longer works.
if (e.KeyCode == Keys.C && e.Modifiers == (Keys.Control | Keys.Shift))
{
//Do work
}
else if (e.KeyCode == Keys.V && e.Modifiers == Keys.Control)
{
//Paste
}
这篇关于如何使用C#多个修饰键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!