I downloaded the Mono 2.6.1 VMware image to test the portability of my Apple IIe emulator, Virtu (http://virtu.codeplex.com/), to Moonlight and hence Linux. I built the project that targets Silverlight 3 (on Windows) and then dropped the output folder onto the VM and opened the TestPage. It was awesome to see the binary portability 'just worked' as I had hoped! ;)
However, I've hit a problem adding support for the 'OEM' keys in the keyboard event handlers. Basically, the values for these keys are not portable in Silverlight - the KeyEventArgs.Key is usually Key.Unknown (see below) so you need to interpret the KeyEventArgs.PlatformKeyCode for each Environment.OSVersion.Platform. The values I'm seeing do not behave the same way as on Windows and Mac OS X, so I was wondering if it was a problem with the Linux keyboard configuration, or maybe even a bug in Moonlight? So given a standard US keyboard layout (http://en.wikipedia.org/wiki/Template:Keyboard), ignoring everything except the main keys (http://en.wikipedia.org/wiki/File:KB_United_States-NoAltGr.svg), scanning from top left to bottom right I press the following OEM keys: `-=[]\;',./ which when shifted should generate ~_+{}|:"<>? instead. Hopefully that makes sense. The following shows the values I get from the Silverlight key event handlers on Windows: KeyPressed KeyEventArgs.Key KeyEventArgs.PlatformKeyCode ` Key.Unknown (0xFF) 0xC0 - Key.Unknown (0xFF) 0xBD = Key.Unknown (0xFF) 0xBB [ Key.Unknown (0xFF) 0xDB ] Key.Unknown (0xFF) 0xDD \ Key.Unknown (0xFF) 0xDC ; Key.Unknown (0xFF) 0xBA ' Key.Unknown (0xFF) 0xDE , Key.Unknown (0xFF) 0xBC . Key.Unknown (0xFF) 0xBE / Key.Unknown (0xFF) 0xBF Shift ` (~) Key.Unknown (0xFF) 0xC0 Shift - (_) Key.Unknown (0xFF) 0xBD Shift = (+) Key.Unknown (0xFF) 0xBB Shift [ ({) Key.Unknown (0xFF) 0xDB Shift ] (}) Key.Unknown (0xFF) 0xDD Shift \ (|) Key.Unknown (0xFF) 0xDC Shift ; (:) Key.Unknown (0xFF) 0xBA Shift ' (") Key.Unknown (0xFF) 0xDE Shift , (<) Key.Unknown (0xFF) 0xBC Shift . (>) Key.Unknown (0xFF) 0xBE Shift / (?) Key.Unknown (0xFF) 0xBF Note that the behaviour is consistent. The KeyEventArgs.Key is always Key.Unknown and the KeyEventArgs.PlatformKeyCode is always the same given the same KeyPressed - regardless of whether or not Shift is being pressed. The following shows the values I get from the Silverlight key event handlers on Linux (specifically the Mono 2.6.1 VMware image): KeyPressed KeyEventArgs.Key KeyEventArgs.PlatformKeyCode ` Key.Unknown (0xFF) 0x31 - Key.Subtract (0x50) 0x14 = Key.Add (0x4F) 0x15 [ Key.Unknown (0xFF) 0x22 ] Key.Unknown (0xFF) 0x23 \ Key.Unknown (0xFF) 0x33 ; Key.Unknown (0xFF) 0x2F ' Key.Unknown (0xFF) 0x30 , Key.Unknown (0xFF) 0x3B . Key.Decimal (0x51) 0x3C / Key.Divide (0x52) 0x3D Shift ` (~) Key.Unknown (0xFF) 0x31 Shift - (_) Key.Subtract (0x50) 0x14 Shift = (+) Key.Add (0x4F) 0x15 Shift [ ({) Key.Unknown (0xFF) 0x22 Shift ] (}) Key.Unknown (0xFF) 0x23 Shift \ (|) Key.Unknown (0xFF) 0x33 Shift ; (:) Key.Unknown (0xFF) 0x2F Shift ' (") Key.Unknown (0xFF) 0x30 Shift , (<) Key.Unknown (0xFF) 0x3B Shift . (>) Key.Unknown (0xFF) 0x3C Shift / (?) Key.Unknown (0xFF) 0x3D Note the inconsistent behaviour. The KeyEventArgs.Key is usually Key.Unknown, but sometimes returns a 'portable' value for the -=./ keys. I say sometimes because when Shift is being pressed then the ./ keys revert to the same behaviour as Windows and return Key.Unknown instead. But the main problem are the -= keys because they never return Key.Unknown. My understanding is they should also be returning Key.Unknown because they are OEM keys (which can be Shifted) and do not represent the numeric keypad keys (which cannot be Shifted). This is stands out as a problem to me because it goes against the grain and makes it trickier than it should be to write portable code, hence my pondering if it was a problem with the Linux keyboard configuration, or maybe even a bug in Moonlight? -- View this message in context: http://old.nabble.com/Strange-KeyEventArgs-Key---PlatformKeyCode-values-tp27473905p27473905.html Sent from the Moonlight mailing list archive at Nabble.com. _______________________________________________ Moonlight-list mailing list [email protected] http://lists.ximian.com/mailman/listinfo/moonlight-list
