我知道如何处理关键事件,即
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’之间辨别怎么办?另外,如果我想处理百分号’%’之类的键,该怎么办?
其他地方有答案.对于那些感兴趣的人……
public 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事件处理程序.
原文地址:https://www.jb51.cc/windows/363402.html
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。