How to convert KeyCode ?

L

Laurent

Hi everyone,

I developped a UserControl and for this control I need to handle the + and -
keys.
The KeyPress event doesn't suit because I want to have an effet when the key
is down and when the key is up.
So, I handle the KeyDown and KeyUp events, but I received KeyCode and not
the translated character.

If the + or - on the numpad is pressed, I receive KeyCode = Add / Subtract
If the + or - on the main keyboard is pressed, I received (first for + , the
shift KeyCode) and then OemPlus, OemMinus.
I do not want to use a trick like memorize that the shift key is pressed
before the plus key is pressed because if the keyboard is configured
differently, it may be not working.

Who know how to convert the KeyCode / KeyData provided by the KeyEventArgs
into a character ?

Thanks
Laurent
 
M

Mattias Sjögren

I do not want to use a trick like memorize that the shift key is pressed
before the plus key is pressed because if the keyboard is configured
differently, it may be not working.

You don't have to remember the shift state, you can check it with
Control.ModiferKeys.


Mattias
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top