简体   繁体   English

如何验证组合键(AltGr + Key)?

[英]How to validate key combinations(AltGr+Key)?

I need to set edit mode for an textbox when press (Alt+Key).I'm using German Keyboard. 我需要在按下(Alt + Key)时为文本框设置编辑模式。我正在使用德语键盘。 I have achieved this in US keyboard but not in German keyboard.i have tried this following code in KeyDown event. 我在美国键盘上实现了此功能,但在德国键盘上却没有实现。

if (e.Modifiers == (Keys.Control | Keys.Alt) 
   && e.KeyData != (Keys.RButton | Keys.LButton | Keys.ShiftKey | Keys.Alt | Keys.Control))
{
  //my code
}

The condition 条件

e.KeyData != (Keys.RButton | Keys.LButton | Keys.ShiftKey | Keys.Alt | Keys.Control) 

will always true when click Alt key alone. 单独单击Alt键时将始终为true。 but in US keyboard this condition will works fine. 但在美式键盘中,这种情况会很好。

Anyone suggest me how to achieve this. 有人建议我如何实现这一目标。

found the reason. 找到了原因。

split this condition e.KeyData != (Keys.RButton | Keys.LButton | Keys.ShiftKey | Keys.Alt | Keys.Control) to 拆分此条件e.KeyData != (Keys.RButton | Keys.LButton | Keys.ShiftKey | Keys.Alt | Keys.Control)

e.KeyData != (Keys.RButton | Keys.ShiftKey | Keys.Control | Keys.Alt)
       && e.KeyData != (Keys.LButton | Keys.ShiftKey | Keys.Control | Keys.Alt)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM