Search code examples
delphipage-refreshchromium-embedded

Delphi Chromium Embedded - Refresh page with F5


I am using Delphi Chromium Embedded in my application, and I have the following question: How can I emulate F5 key to refresh page ?


Solution

  • In the OnKeyEvent use the following code:

    uses
      CEFLib;
    
    procedure TForm1.Chromium1KeyEvent(Sender: TObject;
      const browser: ICefBrowser; event: TCefHandlerKeyEventType; code,
      modifiers: Integer; isSystemKey: Boolean; out Result: Boolean);
    begin
      if (event = KEYEVENT_RAWKEYDOWN) and (code = VK_F5) then
      begin
        Result := True;
        Chromium1.Browser.Reload;
      end;
    end;