giovedì 3 maggio 2012 18:53
When receiving the KeyDown event from the OnScreen keyboard I notice the scan code is always set to 0. The VirtualKey is set so I was thinking I could just use MapVirtualKey\MapVirtualKeyEx to convert that to a scancode. However, those functions are mapped as "Desktop Only". My questions are why does the OnScreen Keyboard not provide a scancode? Or is there at least a Metro mode method where I can convert the VirtualKey to a scancode?
Tutte le risposte
venerdì 4 maggio 2012 09:32Moderatore
Yes, there is no Virtual key for the OnScreen keyboard. And there is no way to screen scraping in metro.
Jesse Jiang [MSFT]
MSDN Community Support | Feedback to us
venerdì 4 maggio 2012 14:43
Screen Scraping? Not sure why you are talking about Screen Scraping in reference to my question.
As for VirtualKey, KeyDown event from XAML controls is providing the correct VirtualKey value from the enumeration. However I have noticed 2 errors.
- No scan code is provided. This is a standard value. If know the current locale identifier this is a 1:1 mapping with Virtual Key. Unfortunately the API to do this is marked as Desktop Only http://msdn.microsoft.com/en-us/library/windows/desktop/ms646307(v=vs.85).aspx.
- CoreWindow.KeyDown event appears to have a bug. While XAML version of event has the correct VirtualKey, this event does not. No matter which character I touch on the OnScreen keyboard receive a VirtualKey value of 231.
sabato 5 maggio 2012 02:37Moderatore
The soft keyboard does not generate scan codes. There is not a 1:1 mapping between VKs and scan codes, and the soft keyboard can generate many keys which do not have matching scan codes (i.e. lower case characters, several of the symbols, and the icons on the face menu). The soft keyboard generates Unicode characters and sends them as though they were keystrokes with the VK_PACKET virtual key.
VK_PACKET is 0xE7 (231) and that is what you see in the KeyDown event. The Xaml KeyDown event converts this into characters, but CoreWindow.KeyDown passes the VK code from WM_KEYDOWN directly. I'll file a report on this difference for you.
venerdì 1 giugno 2012 14:16Are there any plans to provide an equivalent of MapVirtualKey\MapVirtualKeyEx in WinRT?