Hello! Help with writing a program in Delphi about handling keystrokes. The bottom line is this: we have Radigroup with two Radio : onKeyPress and onKeyUp . When the onKeyPress radio button is onKeyPress , the pressed key is displayed in the memo field in the following format:

 KeyPress: <символ>(<код_символа>) 

When the onKeyUp radio button is onKeyUp , the information on the pressed key combination in the following format is displayed in the memo field:

 KeyUp: <нажатая комбинация клавиш>(<код клавиши>) 

Exclude the output of individual lines on the control keys pressed when entering combinations (the key value should not be 16- Shift , 17- Ctrl , 18- Alt ).

I do not quite understand how to associate the event of pressing a RadioGroup with a keystroke on the keyboard.

    1 answer 1

    The easy way: create your onKeyPress and onKeyUp , which will display text in Memo , but do not bind them to the component.

    In the RadioGroupOnChange() handler, depending on the selection, tie one handler and unhook the other.

    • but tell me where to find these character codes? Or do you need to prescribe them yourself? - tkoff
    • You do not need to register. You have a Key: Char character in the event handler. It just needs to be represented as a number. For example, in a hexadecimal system: KeyCodeStr: = Format ('$% x', [Key]); - Nofate