Solved

How i check if CTRL key is pressed when i click on a Button?

Posted on 2004-08-16
2
210 Views
Last Modified: 2010-04-05

I´d like to check if CTRL key is pressed when i click on a Button. Do you know how i implement this?

Best Regards.
0
Comment
Question by:joelsilva
2 Comments
 
LVL 3

Accepted Solution

by:
Tyrsis earned 25 total points
ID: 11817575
Here you go:

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    Memo1: TMemo;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var
    iState : SmallInt;
begin
    if(GetKeyState(VK_CONTROL) < 0) then
    begin
        Memo1.Lines.Add('Control Key Pressed');
    end
    else
    begin
        Memo1.Lines.Add('Control Key NOT Pressed');
    end;
end;

end.
0
 

Author Comment

by:joelsilva
ID: 11817601
Thanks very much... I appreciate so much your answer.
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now