Jump to content
Neron

Key combination

Recommended Posts

i would assume using these to functions check for if one is true then check the other and do a if statement using the and operator. heres some functions :

function IsFunctionKeyDown(Key: Byte): Boolean;

Checks if the given function key is down.

Meanings of Key:

0: SHIFT

1: CONTROL

2: ALT

3: LEFT SHIFT

4: LEFT CONTROL

5: LEFT ALT

6: RIGHT SHIFT

7: RIGHT CONTROL

8: RIGHT ALT

function IsKeyDown(C: Char): Boolean;

Checks if the given key is down.

Example:

if(IsKeyDown('a'))then

Writeln('You have pressed "a". Congratulations!');

 

Heres the code i write to Test:

 

 procedure Checkkeys;
Begin
if (IsFunctionKeyDown(1) and IsKeyDown('a')) then
  Writeln('Both Keys Are Down!')
else
  Writeln('Still Lookin For Keys!');
end; 

 

Here is Function i wrote, Simple and to the point

Function Keys

0: SHIFT

1: CONTROL

2: ALT

3: LEFT SHIFT

4: LEFT CONTROL

5: LEFT ALT

6: RIGHT SHIFT

7: RIGHT CONTROL

8: RIGHT ALT

 

function Checkkeys(FuncKey: Byte; C: Char; WaitTime: Integer):boolean;
Var
T: Integer;
Begin
T := GetSystemTime + WaitTime
 repeat
  if (IsFunctionKeyDown(FuncKey) and IsKeyDown(C)) then
    result := True
  else
    result := False;
 until (T < GetSystemTime) or (result = True);
end;

 

Example :

 
begin
if CheckKeys(1,'a', 5000) = true then//This will check for the keys for 5 seconds then exit;
 writeln('Keys pressed') // Or something more usefule like terminate Script
else
Writeln('Keks Not Pressed');
end.

Edited by shadowrecon
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
  • Create New...