Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
621 views
in Technique[技术] by (71.8m points)

c# - 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!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

56.9k users

...