Question

If I have an onKeyPress event, so I can call it with

var theKey : Char;
....
theKey := #13;  // ENTER key
FormKeyPress(Sender,theKey);

How to call the same way if I have an onKeyDown event ?

Was it helpful?

Solution

It's totally wrong for you to want to do this, because keyboard events are designed to handle user input from the keyboard. You should be executing the code you want directly; you can also use that code from within your key events in response to user input, which clearly separates the user interface from the program logic.

With that being said, you can call the event the same way. For instance, to send Enter:

Key := 13;
FormKeyDown(Sender, Key, []);

To send CtrlK:

Key := Ord('K');
FormKeyDown(Sender, Key, [ssCtrl]);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top