Silverlight处理多个按键组合 [英] Silverlight handling multiple key press combinations

查看:177
本文介绍了Silverlight处理多个按键组合的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Silverlight应用程序,其中我捕获某些按键,如 Tab Ctrl 来执行一些操作。但是,我想要同时处理多个按键,例如 Ctrl + R 或类似的东西。有没有办法在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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆