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;
}
}
Is there an existing issue for this?
CefSharp Version
92.0.260
Operating System
Windows 11
Architecture
x64
.Net Version
.Net4.6
Implementation
WinForms
Reproduction Steps
Expected behavior
Actual behavior
Regression?
No response
Known Workarounds
No response
Does this problem also occur in the CEF Sample Application
Not Tested
Other information
No response