Unicode输入Windows 8.1 Store App

时间:2015-01-20 13:51:22

标签: c# c++ unicode windows-store-apps windows-8.1

如果我按下键盘上的某个键,我想收到正确的本地化Unicode-Char。 (在带有C ++或C#的Windows 8.1 Store App中)

我目前正在通过KeyEventArgs - 事件

接收键盘输入

C ++:

Windows::UI::Core::CoreWindow^ window = Windows::UI::Core::CoreWindow::GetForCurrentThread();
window->KeyDown += ref new Windows::Foundation::TypedEventHandler<Windows::UI::Core::CoreWindow^, Windows::UI::Core::KeyEventArgs^>(this, &ComponentInterface::OnKeyDown);

void ComponentInterface::OnKeyDown(Windows::UI::Core::CoreWindow^ window, Windows::UI::Core::KeyEventArgs^ e)
{
    unsigned int key = e->KeyStatus.ScanCode;
}

1 个答案:

答案 0 :(得分:2)

获取字符句柄CoreWindow::CharacterReceived而不是CoreWindow::KeyDown

KeyDown事件本身只提供密钥,并且不包含足够的上下文来知道最终会生成哪个字符。