OnKeyDown in Delphi 5 and 6 Pro isn't working on my system
Posted on 2001-07-21
I created a form. Set its style to fsMDIForm.
I set the keypreview property to true;
I placed a Statusbar on the form with 6 panels (CAP, Capstatus, NumbLock, NumbLockStatus, Insert, InsStatus)
I placed a ActionList on the form and created a custom action item (Action1). This item will check the status of the keyboard and will change the CapStatus, NumbLockStatus, and InsStatus to either on or off.
When the form is created Action1 is executed and everything works as it should.
But...When I press on the Keyboard key Caps Lock....nothing happens. The OnKeyDown event is Action1.Execute;
I have also tried this code in the OnKeyDown Event just to see if any code will work:
procedure TMainForm.FormKeyDown(Sender: TObject; var Key: Word;
if (shift = ([ssalt])) then showMessage('This Works');
BTW - If I put a timer component on the form and have it fire Action1.Execute (every 1000 ms) it picks up the change to the keyboard state when I change it.
I have tried this in both D5 and D6.