I can’t figure out how to capture the Deletekey press.
I found out that in ASCII code table, it is at 127 place, but if (Key = #127) then got me nowhere.
Then I checked the value of VK_DELETE which was 47. Tried to use that, but it didn’t work.
The KeyPreview := true is set in my form.
I tried to add the ShowMessage(IntToStr(Ord(Key))) to the Forms KeyPress event, but I never got the message popup while clicking the Delete key.
I need to handle the Delete key press in dynamicaly created Edit fields. I want to control what part of the text user can erase in that field, and I know how to handle the text deletion using Backspace key, now need to figure out how to do it with Delete key.
Thanks
You should handle the
OnKeyDowninstead of theOnKeyPressevent. If you do that thenVK_DELETEshould work for you. Note that the parameter forOnKeyDownandOnKeyUpis aWord, not aCharas forOnKeyPress.