1

Here is the code:

        browserControl.KeyDown += new System.Windows.Forms.KeyEventHandler(BrowserControl_KeyDown);

        private void BrowserControl_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.E)
                MessageBox.Show("E");
        }

I assumed that when i entered the browserControl (a CefSharp ChromiumWebBrowser), it will simply give me a message box with the message "E". Obviously! But no, absolutely nothing i am trying to make something there but i don't think i would download a browser where you get stuck in fullscreen mode because none of the shortcut keys work.

Here is another solution i searched up and appearently should work, and it does if i click a button outside the browser, but not when i need it:

        protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
        {
            if (keyData == Keys.E)
            {
                MessageBox.Show("E.. A... GAMES");
            }
            return base.ProcessCmdKey(ref msg, keyData);
        }

I mean come on! I am overriding the whole key process, and still gives me absolutely nothing. What?

  • You can access key events by implementing http://cefsharp.github.io/api/86.0.x/html/T_CefSharp_IKeyboardHandler.htm and assigning an instance to the http://cefsharp.github.io/api/86.0.x/html/P_CefSharp_IWebBrowser_KeyboardHandler.htm property. The chromium message loop doesn't propagate key/mouse/touch events – amaitland Jan 25 '21 at 19:34
  • https://stackoverflow.com/questions/36635808/cefsharp-and-previewkeydown-event-not-working – Alex P. Dec 09 '22 at 10:56

0 Answers0