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

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

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

4条回答
  •  一整个雨季
    2021-01-15 01:53

    Try this:

    var virtualKey = (uint)KeyInterop.VirtualKeyFromKey(e.Key);
    var keyCode = MapVirtualKey(virtualKey, 0);
    

    Import function MapVirtualKey

    [DllImport("user32.dll")]
    static extern uint MapVirtualKey(uint uCode, uint uMapType);
    

提交回复
热议问题