How to trap your own hot keys (Views: 101)


How to trap your own hot keys


Windows has many default hot keys that your interface takes advantage of. However, you sometimes need to add your own hot keys to your form. How do you trap the hot keys when the user enters them?

To solve this problem, first set your form KeyPreview property to True. Next, add this line of code to your form's OnKeyDown event handler:

if (ssCtrl in Shift) and (chr(Key) in ['A', 'a']) then

The OnKeyDown event will trap the keystrokes and perform the specified code in response.

<< Back to main page