could someone please tell me the identifier for the @ key?
for example keys.Escape is for the ESC key. i would like to know what it is for @
thank you.
could someone please tell me the identifier for the @ key?
for example keys.Escape is for the ESC key. i would like to know what it is for @
thank you.
On my keyboard it is Keys.D2 because @ is the same key as digit 2.
However, if you handle KeyPress event you get KeyPressEventArgs in the argument that has KeyPressEventArgs.KeyChar property. And this property contains a character rather than keycode.
The KeyCode is what you get in KeyDown and KeyUp events. Since this is a shifted character, it depends on the keyboard layout. As far as I know, most keyboards have it above the digit 2, and that means checcking for e.Shift && e.KeyCode == Keys.D2
(WinForms). But on some most international keyboards, this will not work.
But note that handling the KeyPress event is much more reliable: e.KeyChar == '@'
Edit: I took a quick look at this page, and most international keyboards have the "
over the 2
key and use Alt-something to get a @
.
You should not use the KeyDown event to recognize typing keys like @. The translation from virtual key code (KeyEventArgs.KeyData) to a typing key is dependent on the keyboard layout. Which is probably different in the UK from the one in the USA, you've got a pound to squeeze in somewhere. And surely different on a keyboard in a far East location.
Use the KeyPressed event instead.