Is there a way to get the OnKeyDown event when the VK_LEFT key is pressed on a TCheckBox or TButton control. Currently, it just selects another control, but does not fire this event.
UPDATE
Here is my code to use the VK_LEFT key, like TAB Back.
First, I needed to disable the standard VK_LEFT behavior on some controls (TCheckBox, TButton, ...):
procedure TfmBase.CMDialogKey(var Message: TCMDialogKey); begin if Message.CharCode <> VK_LEFT then inherited; end;
then the OnKeyDown event is also fired for VK_LEFT on TCheckBox, TButton, ... In this case, I put the code to select the previous control. Of course, KeyPreview should be true.
procedure TfmBase.FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); var handled: Boolean; begin if Key = VK_LEFT then begin handled := false; TabBack(handled); //This is my function, which checks the type of the control and selects the previous control. if handled then Key := 0; end; end;
source share