Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8465579
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T15:05:28+00:00 2026-06-10T15:05:28+00:00

I have a form with 2 CheckBoxes (1 is for holding CTRL – 1

  • 0

I have a form with 2 CheckBoxes (1 is for holding CTRL – 1 is for holding ALT).
Both CheckBoxes are disabled so the KeyDown Event of the form works properly.
There is also a TTimer that synchronizes every 10ms if the ALT/CTRL key is pressed.

My timer:

procedure TForm1.Timer1Timer(Sender: TObject);
begin
 CheckBox1.Checked := ALTDOWN;  // ALTDOWN IS GLOBAL
 CheckBox2.Checked := CTRLDOWN; // CTRLDOWN IS GLOBAL
end;

My KeyDown Event:

procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
 if Key = VK_MENU then begin
  ALTDOWN := TRUE;
  exit;
 end;
 if Key = VK_CONTROL then begin
  CTRLDOWN := TRUE;
  exit;
 end;
end;

My KeyUP Event:

procedure TForm1.FormKeyUp(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
 if Key = VK_MENU then begin
  ALTDOWN := FALSE;
  exit;
 end;
 if Key = VK_CONTROL then begin
  CTRLDOWN := FALSE;
  exit;
 end;
end;

This works without any problems with the CTRL key.
But the ALT key get’s stuck sometimes or does not even show up at all.
This happens when I press ONLY the ALT key (without any other keys in combination).

Why is that and how can I fix this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T15:05:30+00:00Added an answer on June 10, 2026 at 3:05 pm

    If you are going to run a timer in that way, then you may as well just call GetAsyncKeyState

    procedure TForm1.Timer1Timer(Sender: TObject);
    begin
     CheckBox1.Checked := GetAsyncKeyState(VK_MENU)<0;
     CheckBox2.Checked := GetAsyncKeyState(VK_CONTROL)<0;
    end;
    

    And just get rid of your OnKeyDown and OnKeyUp event handlers. There’s really no point in you trying to keep track of whether the key is up or down when the system already does so.

    Your timer interval is quite short. The system won’t fire them that frequently anyway. If I recall correctly the timer resolution is typically around 50ms.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a form which have five buttons and several checkboxes holding different values.
I have to send an email which contains some checkboxes.My aspx form also have
I have a form, and inside it there's a while() with checkboxes. I wish
I have a HTML form containing checkboxes in the form of .. <input type=checkbox
i have a form with some checkboxes on it i want to save those
i have a form that contains checkboxes. I've named the checkboxes as stream[], so
i have form in drupal which uploads images and has got few checkboxes in
I have issue with: <form:checkboxes path=roles cssClass=checkbox items=${roleSelections} /> If previous line is used
I am working on zend. I have a form with some checkboxes. I want
I have a form with radio buttons and checkboxes. I have a textarea before

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.