如何检测何时在OEM键C#中按下了(向前)斜杠键 [英] How to detect when (forward) slash key is pressed in OEM keys C#

查看:103
本文介绍了如何检测何时在OEM键C#中按下了(向前)斜杠键的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用wpf c#应用程序,我需要检测用户何时按"/",但是在查找"/" e.Key时遇到了麻烦,我看到有Key.OemBackslash之类的东西,但我找不到"/"的正确事件(正斜杠)...

I'm working on wpf c# application and I need to detect when user press "/" but I'm having trouble with finding " / " e.Key, I saw there is Key.OemBackslash and stuffs like that, but I can't find right event for " / " (forward slash) ...

谢谢大家, 干杯

推荐答案

在美国键盘上应为Key.OemQuestion.但是在瑞典语键盘上,它是D7,所以要视情况而定.键盘上的键并不总是产生相同的字符.

It should be Key.OemQuestion on a US keyboard. But on a Swedish keyboard it is D7 so it depends. The keys on the keyboard doesn't always produce the same character.

根据您要执行的操作,最好处理PreviewTextInput事件:

Depending on what you are trying to do you may be better off handling the PreviewTextInput event:

protected override void OnPreviewTextInput(TextCompositionEventArgs e)
{
    base.OnPreviewTextInput(e);
    if (e.Text == "/")
    {
        Debug.WriteLine("...");
    }
}

这篇关于如何检测何时在OEM键C#中按下了(向前)斜杠键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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