Articles   Members Online:
-Article/Tip Search
-News Group Search over 21 Million news group articles.
-Delphi/Pascal
-CBuilder/C++
-C#Builder/C#
-JBuilder/Java
-Kylix
Member Area
-Home
-Account Center
-Top 10 NEW!!
-Submit Article/Tip
-Forums Upgraded!!
-My Articles
-Edit Information
-Login/Logout
-Become a Member
-Why sign up!
-Newsletter
-Chat Online!
-Indexes NEW!!
Employment
-Build your resume
-Find a job
-Post a job
-Resume Search
Contacts
-Contacts
-Feedbacks
-Link to us
-Privacy/Disclaimer
Embarcadero
Visit Embarcadero
Embarcadero Community
JEDI
Links
How to detect if Ctrl, Alt or Shift key is pressed Turn on/off line numbers in source code. Switch to Orginial background IDE or DSP color Comment or reply to this aritlce/tip for discussion. Bookmark this article to my favorite article(s). Print this article
10-Oct-02
Category
Win API
Language
Delphi All Versions
Views
150
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			Author: Misha Moellner 

How to detect if Ctrl, Alt or Shift key is pressed

Answer:

1   function CtrlDown: Boolean;
2   var
3     State: TKeyboardState;
4   begin
5     GetKeyboardState(State);
6     Result := ((State[vk_Control] and 128) <> 0);
7   end;
8   
9   function ShiftDown: Boolean;
10  var
11    State: TKeyboardState;
12  begin
13    GetKeyboardState(State);
14    Result := ((State[vk_Shift] and 128) <> 0);
15  end;
16  
17  function AltDown: Boolean;
18  var
19    State: TKeyboardState;
20  begin
21    GetKeyboardState(State);
22    Result := ((State[vk_Menu] and 128) <> 0);
23  end;
24  
25  The following example demonstrates checking if the Shift key is pressed during a 
26  Button Click. 
27  
28  procedure TForm1.Button1Click(Sender: TObject);
29  begin
30    if ShiftDown then
31      Form1.Caption := 'Shift'
32    else
33      Form1.Caption := 'No Shift';
34  end;


			
Vote: How useful do you find this Article/Tip?
Bad Excellent
1 2 3 4 5 6 7 8 9 10

 

Advertisement
Share this page
Advertisement
Download from Google

Copyright © Mendozi Enterprises LLC