A problem with the code presented in my previous post is that it won’t work with the special case of the Backspace key, however it can still be handled with a few small additions, based on the code I found in this question on the Awesomium forums. I have changed my code to the following:
WebKeyboardEvent webKeyboardEvent = new WebKeyboardEvent(); if (character == '\b') { webKeyboardEvent.Type = WebKeyboardEventType.KeyDown; webKeyboardEvent.VirtualKeyCode = VirtualKey.BACK; webView.InjectKeyboardEvent(webKeyboardEvent); webKeyboardEvent.Type = WebKeyboardEventType.KeyUp; webView.InjectKeyboardEvent(webKeyboardEvent); } else { webKeyboardEvent.Type = WebKeyboardEventType.Char; webKeyboardEvent.Text = new String(new char[] { character, (char)0, (char)0, (char)0 }); webView.InjectKeyboardEvent(webKeyboardEvent); } |