Why is the Silverlight Key enum missing common characters like comma and period?
Short version is, the keys we left out are harder than you might think to support, and they weren't necessary for the scenarios we focused on (tabbing around forms, writing common controls, accelerated keys, etc.).
The longer version requires a little background on how keyboards differ across various languages, especially on Mac. Different languages have different keyboards -- eg, in English, the comma and period are on separate keys, but some European keyboards put them on the same key. Windows has an abstraction called the virtual key code (eg, OemPeriod), which is what the KeyDown event returns. Unfortunately Mac doesn't have a concept of virtual key -- they have keyboard-dependent scan codes and they have Unicode, but they don't have the thing that sits in between on Windows called virtual keys. For alphanumeric and a couple other common keys, Mac uses the same scan code for all languages, but for the rest of the keys they make no promises. So if Silverlight wanted to support some of these keys on Mac, we would need to create our own mapping layer -- eg. for Russian, scan code 1373 => OemPeriod, for Japanese scan code 528 => OemPeriod... It could be done, but didn't seem like the best use of resources, so we handled the most common cases and give you PlatformKeyCode for the rest.
Comments
Anonymous
January 22, 2009
PingBack from http://blogs.msdn.com/nickkramer/archive/2009/01/23/why-is-the-silverlight-key-enum-missing-common-characters-like-comma-and-period.aspxAnonymous
January 23, 2009
I appreciate decisions like this. Thanks for posting about it.Anonymous
January 23, 2009
Thanks for posting this. Good place to send whiners on the forums when they complain about Silverlight "missing" featuresAnonymous
January 24, 2009
Nice. Just an idea: you can provide a utility library with helpful extension methods that do the heavy lifting as part of the SDK :)Anonymous
March 04, 2009
The comment has been removed