Linux intercept key when application is minimise (SOLVED) lazarus / 32-Linux ---------------------------------------------------------------------- TheLastCayen · 2019-11-06 21:38 Hi, I am using :  - Linux Mint Xfce 64 bit  - Lazarus 2.0.6 64 bit  - FPC 3.0.4 I am developing an application that should run in the background. I want to be able to start or stop a timer on that application when I push F5. When my application loses focus, The F5 key is not working anymore. This is my code: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState  );begin  begin    IF Key = VK_F5 then      begin        if Timer1.Enabled then          begin            Timer1.Enabled:=False;          ShowMessage('Timer is now Disable');          end        else          begin            Timer1.Enabled:=True;            ShowMessage('Timer is now Enable');          end      end;  end;end; Anyone know a way to intercept the F5 key when my application is minimized? ---------------------------------------------------------------------- winni · 2019-11-06 22:40 Hi! Not so easy. You have to look for "keyboard hook". Here the search results from the forum: https://forum.lazarus.freepascal.org/index.php?action=search2 Good luck! Winni ---------------------------------------------------------------------- TheLastCayen · 2019-11-07 00:03 Thank you for the quick reply. I did a search and I found that post: https://forum.lazarus.freepascal.org/index.php/topic,41307.msg286642.h tml#msg286642 Apparently you can do it using  Codebot.Input.hotkeys but I can't find it under my Lazarus component or any documentation on how to add it in my project. I think this is the GitHub page for the project. https://github.com/sysrpl/Cross.Codebot I can't find more information about Codebot:( I never try to add something like that to one of my projects. Can someone point me to documentation on how to add Codebot.Input.hotkeys to my project? ---------------------------------------------------------------------- TheLastCayen · 2019-11-07 01:25 I found how to deal with Cross.Codebot. for future reference: add to your project ../Cross.Codebot-master/source/codebotctrls.lpk This is my code: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i unit Unit1; {$mode objfpc}{$H+} interface uses  Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls,  LCLType, ExtCtrls, Codebot.Input.Hotkeys; type   { TForm1 }   TForm1 = class(TForm)    Label1: TLabel;    LabeledEdit1: TLabeledEdit;    Timer1: TTimer;    procedure FormCreate(Sender: TObject);    procedure FormDestroy(Sender: TObject);    procedure Timer1StartTimer(Sender: TObject);    procedure Timer1Timer(Sender: TObject);    procedure KeyPressed(Sender: TObject; Key: Word; Shift: TShiftState);  private   public   end; var  Form1: TForm1; implementation{$R *.lfm} { TForm1 }Const  verbose = True; procedure TForm1.FormCreate(Sender: TObject);begin  HotkeyCapture.RegisterNotify(VK_F5,[],@KeyPressed);end; procedure TForm1.FormDestroy(Sender: TObject);begin  HotkeyCapture.UnRegisterNotify(VK_F5,[]);end;  procedure TForm1.Timer1StartTimer(Sender: TObject);begin   Timer1.Interval:=strtoint(LabeledEdit1.Text);end; procedure TForm1.Timer1Timer(Sender: TObject);begin    if verbose then ShowMessage('1 Timer cycle')end; procedure TForm1.KeyPressed(Sender: TObject; Key: Word; Shift: TShiftState);begin  if Timer1.Enabled then    begin      Timer1.Enabled:=False;      if verbose then ShowMessage('Timer is now Disable');    end  else    begin      if verbose then ShowMessage('Timer is now Enable');      Timer1.Enabled:=True;    endend; end.