Silverlight处理多个按键组合 [英] Silverlight handling multiple key press combinations
本文介绍了Silverlight处理多个按键组合的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
解决方案
看看 ModifierKeys枚举以检查多个按键组合。有关代码示例和更多信息,请参阅 Silverlight键盘支持
void Canvas_KeyUp(object sender,KeyEventArgs e)
{
//检查具体的 v'键,然后检查修饰符
if(e.Key == Key.V){
if((Keyboard.Modifiers& ModifierKeys.Control)== ModifierKeys.Control){
//具体的Ctrl + V动作这里
}
} //其他忽略击键
}
I have a Silverlight application in which I catch certain key presses such as Tab or Ctrl to perform some action. However, I want to be able to handle multiple keys pressed at the same time such as Ctrl + R or something like that. Is there any way to do that in Silverlight, and if so, how?
解决方案
Take a look at the ModifierKeys Enumeration to check for multiple key press combinations. See Silverlight Keyboard Support for code samples and more information.
void Canvas_KeyUp(object sender, KeyEventArgs e)
{
//check for the specific 'v' key, then check modifiers
if (e.Key==Key.V) {
if ((Keyboard.Modifiers & ModifierKeys.Control) == ModifierKeys.Control) {
//specific Ctrl+V action here
}
} // else ignore the keystroke
}
这篇关于Silverlight处理多个按键组合的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文