Key := 0
Also note that "
Key" is an argument with the "
var" modifier, allowing modification. This is almost always necessary to reset it ("
Key:=0;") after processing, so that subsequent keypress handlers (either those of other components or the default handler) won't be called:
if (Key = VK_F4) and (Shift = [ssAlt]) then
begin
...
Key := 0; // key handled
end;
This is a very good example for this key, which demonstrates:
1. You can override the behavior of some standard "system" keys, such as
[Alt+F4] for closing a window.
2. If you don't specify the key as processed, its processing will continue and reach the default window handler, causing the window to close ))