How to convert KeyCode ?

  • Thread starter Thread starter Laurent
  • Start date Start date
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
 
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
 
Back
Top