Hello All,
I would like to change the function of a key. There is a key next to Alt-Gr key on the right side on keyboard. It is between Alt-Gr and Ctrl keys. It's virtual code is VK_APPS. This key has a the same function with the mouse right click. I want to prevent it's normal function, but can not succeed. Instead, it should send a space character to Memo1. Program, gets locked when popup menu appears or sometimes, Memo1 is cleared. I mean it is not working stable. And I also want to add Ctrl+C function to Button1 to copy the content of Memo1.
unit Unit1;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls,
MouseAndKeyInput, LCLType;
type
{ TForm1 }
TForm1 = class(TForm)
Button1: TButton;
Memo1: TMemo;
procedure Memo1KeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
private
public
procedure SendKeys(Data: PtrInt);
end;
var
Form1: TForm1;
implementation
{$R *.lfm}
{ TForm1 }
procedure TForm1.Memo1KeyDown(Sender: TObject; var Key: Word; Shift: TShiftState
);
begin
if (Key = VK_APPS) then
begin
Application.QueueAsyncCall(@SendKeys, 0);
end;
end;
procedure TForm1.SendKeys(Data: PtrInt);
begin
Memo1.SetFocus;
Application.ProcessMessages ;
KeyInput.Press(VK_SPACE);
end;
end.