How do you get the character appropriate for the given KeyDown event?

后端 未结 4 1938
粉色の甜心
粉色の甜心 2021-01-15 01:27

How do you get the character appropriate for the given KeyDown event in WPF?

4条回答
  •  伪装坚强ぢ
    2021-01-15 01:37

    private void UserControl1_KeyDown_1(object sender, KeyEventArgs e)
    {   
        FieldInfo field = e.GetType().GetField
        (
           "_scanCode",
           BindingFlags.NonPublic |
           BindingFlags.Instance
        );
    
        Int32 scancode = (Int32)field.GetValue(e);
    
        char c = (char)scancode;
    }
    

提交回复
热议问题