Skip to content

Typing "shift + {" will open the DevTool automatically, typing "t" in textbox on the web page will refresh the web page automatically #4871

@xiedongweo

Description

@xiedongweo

Is there an existing issue for this?

  • I have searched both open/closed issues, no issue already exists.

CefSharp Version

92.0.260

Operating System

Windows 11

Architecture

x64

.Net Version

.Net4.6

Implementation

WinForms

Reproduction Steps

public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            var browser = new ChromiumWebBrowser("https://cn.bing.com/");
            browser.KeyboardHandler = new PreviewKeyboardHandler();
            this.Controls.Add(browser);
            browser.Dock = DockStyle.Fill;
        }
    }

    public class PreviewKeyboardHandler : IKeyboardHandler
    {

        public PreviewKeyboardHandler()
        {
        }


        public bool OnKeyEvent(IWebBrowser chromiumWebBrowser, IBrowser browser, KeyType type, int windowsKeyCode, int nativeKeyCode, CefEventFlags modifiers, bool isSystemKey)
        {
            return false;
        }

        public bool OnPreKeyEvent(IWebBrowser chromiumWebBrowser, IBrowser browser, KeyType type, int windowsKeyCode, int nativeKeyCode, CefEventFlags modifiers, bool isSystemKey, ref bool isKeyboardShortcut)
        {
            if (!chromiumWebBrowser.IsBrowserInitialized)
            {
                return false;
            }

            switch ((Keys)windowsKeyCode)
            {
                case Keys.F12:

                        browser.ShowDevTools();
                    break;
                case Keys.F5:
                    if (modifiers == CefEventFlags.ControlDown)
                    {
                        // ctrl + F5
                        browser.Reload(true);
                    }
                    else
                    {
                        // F5
                        browser.Reload();
                    }
                    break;
            }

            return false;
        }
}

Expected behavior

  1. typing "shift + {", I want the "{" occurred in the textbox, instead of openning the Devtool.
  2. typing "t", I want the "t" character occurred in the textbox, instead of reloading the web page.

Actual behavior

  1. typing "shift + {", the "{" doesn't occurred in the textbox, but it opened the Devtool.
  2. typing "t", the "t" character doesn't occurred in the textbox, but it reloaded the web page.

Regression?

No response

Known Workarounds

No response

Does this problem also occur in the CEF Sample Application

Not Tested

Other information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions