What is the KeyCode for ","(comma) and "."(dot) in .NET?

Bosak picture Bosak · Jan 18, 2012 · Viewed 96.6k times · Source

In my KeyDown EventHandler I need to know what is the KeyCode for "," and ".".

I can't find them thats why I ask. Thanks!

Answer

CodesInChaos picture CodesInChaos · Jan 18, 2012

A key and a character are not the same thing. The keyboard layout transforms between them, and that transform isn't trivial. Probably you're doing the wrong thing when using KeyDown. If you want to know which character a user entered you should use KeyPress, which gives the the already translated character.

For example Keys.Decimal is a key on the numpad that corresponds to . on the US layout, and , on the German layout. Keys.Oemcomma and OemPeriod are likely , and . belows the letters. But on other layouts that may be different.