Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

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

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

791 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