'How to use Delphi onKeyPress to make changes to a TImage, for example: to hind the image if certain is pressed down

I need to make a Timage item hide or disappear after a certain key is being pressed, while the program is still running.

I know that onKeyPress method can't really make changes to the Graphic items such like Timage, so is there any other alternative ways which I could use for my situation?



Solution 1:[1]

Set KeyPreview of the form to true and write an OnKeyPress|Down|Up event for the form, where you hide that TImage.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Delphi Coder