Solved

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

Posted on 2004-08-16
2
211 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Delphi OLE Error 8 96
Copy file in dll not working but working on exe ! 18 88
Working this component WebCopy with proxy, help 3 76
RESTRequest Parameter 4 15
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 my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…

863 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

25 Experts available now in Live!

Get 1:1 Help Now