Loading ...
Sorry, an error occurred while loading the content.

IsKeyPressed

Expand Messages
  • j00j00633
    Just wondering... ~ means ENTER + means SHIFT ^ means CTRL % means ALT How would I check to see if those keys are pressed in IsKeyPressed ();? Or is it
    Message 1 of 1 , Aug 21, 2003
    View Source
    • 0 Attachment
      Just wondering...

      ~ means ENTER
      + means SHIFT
      ^ means CTRL
      % means ALT

      How would I check to see if those keys are pressed in IsKeyPressed
      ();? Or is it possible? Or will it be possible? How about CTRL+Key or
      ALT+Key or SHIFT+Key?

      Changes for 1.50? Ends at 1.49.2 in the 'CHANGES' file.


      [SNIP]
      function CtrlDown : Boolean;
      var
      State : TKeyboardState;
      begin
      GetKeyboardState(State);
      Result := ((State[vk_Control] And 128) <> 0);
      end;

      function ShiftDown : Boolean;
      var
      State : TKeyboardState;
      begin
      GetKeyboardState(State);
      Result := ((State[vk_Shift] and 128) <> 0);
      end;

      function AltDown : Boolean;
      var
      State : TKeyboardState;
      begin
      GetKeyboardState(State);
      Result := ((State[vk_Menu] and 128) <> 0);
      end;

      {
      The following example demonstrates checking if the
      Shift key is pressed during a Button Click.
      }

      procedure TForm1.Button1Click(Sender: TObject);
      begin
      if ShiftDown then
      Form1.Caption := 'Shift' else
      Form1.Caption := 'No Shift';
      end;
      [/SNIP]

      Can that help?
    Your message has been successfully submitted and would be delivered to recipients shortly.