Search code examples
c#wpfsocketskeystrokes

c# wpf catch win key code from previewkeydown event handler


i need to obtain the windows low level key code ( http://msdn.microsoft.com/en-us/library/windows/desktop/dd375731(v=vs.85).aspx ) intercepting input from UIElement.PreviewKeyDown() for send it via socket and share these with another host. Is there any way for it?


Solution

  • I believe what you are looking for is System.Windows.Input.KeyInterop. Here is how you use it:

    private void previewKeyDownHandler(object sender, KeyEventArgs e){
       var vk = KeyInterop.VirtualKeyFromKey(e.Key);
       //....
    }