Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

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

like image 827
Bosak Avatar asked Jan 18 '12 18:01

Bosak


People also ask

What is e keyCode === 13?

key 13 keycode is for ENTER key.

What is the keyCode for the spacebar?

the keyCode=49 for a space.

What is keyCode C#?

C# KeyCode Property and KeyDownUse the KeyCode property in Windows Forms to detect the Enter key. KeyCode handles key presses. You have a TextBox control on your Windows Forms application and need to detect Enter.


2 Answers

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.

like image 165
CodesInChaos Avatar answered Sep 24 '22 13:09

CodesInChaos


Oemcomma and OemPeriod look like good candidates.

Look at the Keys enumeration on MSDN.

like image 21
Oded Avatar answered Sep 25 '22 13:09

Oded