简体   繁体   中英

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. 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. 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.ShiftKey | Keys.Control | Keys.Alt)
       && e.KeyData != (Keys.LButton | Keys.ShiftKey | Keys.Control | Keys.Alt)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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