A little clearer, I think: the OnKeyUp and OnKeyDown events are fired for
any key, so when you press the backspace, or delete, or home, or end, or whatever key your code goes on to test whether it's in that set and, since they are not, it launchs the
ShowMessage().
One way to solve it is to make a set of permitted "edit" keys and test that the key is
neither in that set nor in the "allowed" ones (A..Z, etc.); something like:
if not ((Key in EditKeys) or (Key in ['A'..'Z','a'..'z','0'..'9','.','-'])) then ...