Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using arrow keys as tabbers 2

Status
Not open for further replies.

ukusa

Programmer
Oct 8, 2001
49
AU
hiya,

I have a user who is yelling out to use the arrow keys, at least "up" and "down" to tab from one field to another. I've explained that tabbing is the usual way for most programs but stubbonly he won't do it. How do I trap and get it to tab for me?

Thanks
Allen Crisell
 
Hello, the following should work fine, you will need to set KeyPreview := true in order to capture the keys properly in the first place.
Code:
procedure TForm1.FormKeyUp(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin

//press down shift key...
        if key = vk_up then windows.keybd_event(vk_shift,0 ,0 ,0);
//press down tab key...
        if key = vk_up then windows.keybd_event(vk_tab,0 ,0 ,0);
        if key = vk_down then windows.keybd_event(vk_tab,0 ,0 ,0);
//release tab key...
        if key = vk_up then windows.keybd_event(vk_tab,0,KEYEVENTF_KEYUP ,0);
        if key = vk_down then windows.keybd_event(vk_tab,0,KEYEVENTF_KEYUP ,0);
//release shift key...
        if key = vk_up then windows.keybd_event(vk_shift,0,KEYEVENTF_KEYUP ,0);

end;
Hope this works ok for you,
Justin Willis.
 
Thanks Justin,

Really appreciate it!

"Give the man a raise"

 
Later...

Works brilliantly! I shan't forget about this block of code.

thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top