private void OnGUI() { if (!isFocus) { return; } Event e = Event.current; if (e.isKey || e.functionKey) { cef.SendKeyCharEvent(e.character); CefUnityLib.Helpers.UKeys key = CefUnityLib.Helpers.UKeys.None; CefUnityLib.Helpers.UKeys modifiers = CefUnityLib.Helpers.UKeys.None; Enum.TryParse(e.keyCode.ToString(), out key); Enum.TryParse(e.modifiers.ToString(), out modifiers); switch (e.type) { case EventType.KeyDown: // Debug.Log(e.keyCode+"---"+key+"---"+e.modifiers+"---"+modifiers); cef.SendKeyEvent(KeyEventPipeMessage.TYPE_KEY_DOWN, (CefUnityLib.Helpers.Keys)key, (CefUnityLib.Helpers.Keys)modifiers); break; case EventType.KeyUp: cef.SendKeyEvent(KeyEventPipeMessage.TYPE_KEY_UP, (CefUnityLib.Helpers.Keys)key, (CefUnityLib.Helpers.Keys)modifiers); break; } } }
private void Form1_KeyDown(object sender, KeyEventArgs e) { pictureBox1.Focus(); _controller.SendKeyEvent(KeyEventPipeMessage.TYPE_KEY_DOWN, (CefUnityLib.Helpers.Keys)e.KeyCode, (CefUnityLib.Helpers.Keys)e.Modifiers); e.Handled = true; }