whats new ¦  programming tips ¦  indy articles ¦  intraweb articles ¦  informations ¦  links ¦  interviews
 misc ¦  tutorials ¦  Add&Win Game

Tips (1541)

Database (90)
Files (137)
Forms (107)
Graphic (114)
IDE (21)
Indy (5)
Internet / LAN (130)
IntraWeb (0)
Math (76)
Misc (126)
Multimedia (45)
Objects/
ActiveX (51)

OpenTools API (3)
Printing (35)
Strings (83)
System (266)
VCL (242)

Top15

Tips sort by
component


Search Tip

Add new Tip

Add&Win Game

Advertising

21 Visitors Online


 
...find the appropriate constant for virtual keys?
Autor: Home-Building (Christian)
Homepage: http://home.t-online.de/home/Home-Building
[ Print tip ]  

Tip Rating (12):  
     


// Keyboard Codes:

// Useful If you don't have the Source-Code from Windows.pas
// Nützlich, wenn man den Source-Code von der Windows Unit nicht hat.

        
vk_LButton
        vk_RButton
        vk_Cancel
        vk_MButton
        vk_Back
        vk_Tab
        vk_Clear
        vk_Return
        vk_Shift
        vk_Control
        vk_Menu
        vk_Pause
        vk_Capital
        vk_Escape
        vk_Space
        vk_Prior
        vk_Next
        vk_Home
        vk_Left
        vk_Up
        vk_Right
        vk_Down
        vk_Select
        vk_Print
        vk_Execute
        vk_SnapShot
        vk_Insert
        vk_Delete
        vk_Help

        vk_NumPad0 vk_NumPad1 vk_NumPad2 vk_NumPad3
        vk_NumPad4 vk_NumPad5 vk_NumPad6 vk_NumPad7
        vk_NumPad8 vk_NumPad9

        vk_Multiply
        vk_Add
        vk_Separator
        vk_Subtract
        vk_Decimal
        vk_Divide

        vk_F1 vk_F2 vk_F3 vk_F4 vk_F5 vk_F6 vk_F7 vk_F8
        vk_F9 vk_F10 vk_F11 vk_F12 vk_F13 vk_F14 vk_F15
        vk_F16 vk_F17 vk_F18 vk_F19 vk_F20 vk_F21 vk_F22
        vk_F23 vk_F24

        vk_NumLock
        vk_Scroll


// OnKeyDown fires when the user presses a key.
// Das Ereignis OnKeyDown wird ausgelöst, wenn der Benutzer eine Taste drückt.

procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
  if 
Key = (*Keyboard Code*) then
    
ShowMessage('OnKeyDown'); //Or other thing
end;

{ Es geht auch mit OnKeyPress (dort funktionieren aber nicht alle Keyboard Codes):
 Or trap a Key in the OnKeyPress event (note that not all Keyboard Codes work there}

procedure TForm1.FormKeyPress(Sender: TObject; var Key: Char);
begin
  if 
(Key = chr(vk_Return)) then
    
ShowMessage('OnKeyPress');
end;


 

Rate this tip:

poor
very good


Copyright © by SwissDelphiCenter.ch
All trademarks are the sole property of their respective owners