我知道如何处理关键事件,即
private void Page_KeyUp(object sender,KeyRoutedEventArgs e) { switch (e.Key) { case Windows.System.VirtualKey.Enter: // handler for enter key break; case Windows.System.VirtualKey.A: // handler for A key break; default: break; } }
但是如果我需要在小写’a’和大写’A’之间辨别怎么办?另外,如果我想处理百分号’%’之类的键,该怎么办?
其他地方有答案.对于那些感兴趣的人……
原文链接:https://www.f2er.com/windows/363402.htmlpublic Foo() { this.InitializeComponent(); Window.Current.CoreWindow.CharacterReceived += KeyPress; } void KeyPress(CoreWindow sender,CharacterReceivedEventArgs args) { args.Handled = true; Debug.WriteLine("KeyPress " + Convert.tochar(args.KeyCode)); return; }
更好的是,移动Window.Current.CoreWindow.CharacterReceived = KeyPress;进入GotFocus事件处理程序,并添加Window.Current.CoreWindow.CharacterReceived – = KeyPress;进入LostFocus事件处理程序.